import { VNode } from './vnode' export const SuspenseSymbol = __DEV__ ? Symbol('Suspense key') : Symbol() export interface SuspenseBoundary< HostNode, HostElement, HostVNode = VNode > { vnode: HostVNode parent: SuspenseBoundary | null contentTree: HostVNode | null oldContentTree: HostVNode | null fallbackTree: HostVNode | null oldFallbackTree: HostVNode | null deps: number isResolved: boolean bufferedJobs: Function[] onRetry(fn: Function): void retry(): void onResolve(fn: Function): void resolve(): void } export function createSuspenseBoundary( vnode: VNode, parent: SuspenseBoundary | null ): SuspenseBoundary { let retry: Function let resolve: Function const suspense: SuspenseBoundary = { vnode, parent, deps: 0, contentTree: null, oldContentTree: null, fallbackTree: null, oldFallbackTree: null, isResolved: false, bufferedJobs: [], onRetry(fn: Function) { retry = fn }, retry() { retry() }, onResolve(fn: Function) { resolve = fn }, resolve() { resolve() } } return suspense }