import { type ReactiveController, type ReactiveControllerHost } from "@knyt/tasker"; import type { KnytContent } from "@knyt/weaver"; import type { PromiseReference } from "./PromiseReference.ts"; /** * @internal scope: module */ type DeferredContentHost = ReactiveControllerHost & HTMLElement; /** * @internal scope: module */ export declare class DeferredContentRenderer> implements ReactiveController { #private; constructor(host: DeferredContentHost, references: T); /** * @internal scope: module */ hostConnected(): void; /** * @internal scope: module */ hostDisconnected(): void; /** * Creates a render function that defers rendering while any of the * promises of the previously given references are unresolved. * * @remarks * * Whenever any of the references change, the rendering will be deferred again * until all new promises have resolved. * * While the rendering is deferred, a `DeferredContent` component higher in the * DOM tree may display a placeholder UI while loading is in progress. * * When all promises have resolved, the provided render function is called * with the resolved values, and its result is rendered. However, if any other * elements are being deferred under the `DeferredContent` element, the * placeholder will continue to be shown until all deferred content is ready. */ thenRender(renderFn: (...data: PromiseReference.Collection.Unwrapped) => KnytContent | Promise): () => KnytContent | Promise; /** * Cleans up resources used by the controller and removes it from the host. */ destroy(): void; } /** * Signals a parent `DeferredContent` element to delay revealing its * content until the provided promise settles. */ export declare function defer(host: DeferredContentHost, promise: Promise): void; /** * Signals a parent `DeferredContent` element to delay revealing its * content while any of the promises of the given references are unresolved. * * @remarks * * The returned `DeferredContentRenderer` instance can be used to create * a render function that receives the resolved values of the promises. * This allows rendering the content with the resolved data once all * promises have settled. */ export declare function defer>(host: DeferredContentHost, ...references: T): DeferredContentRenderer; export declare namespace defer { /** * @internal scope: workspace */ type Renderer> = DeferredContentRenderer; } export {}; //# sourceMappingURL=defer.d.ts.map