UNPKG

@thi.ng/rdom

Version:

Lightweight, reactive, VDOM-less UI/DOM components with async lifecycle and @thi.ng/hiccup compatible

32 lines 1.12 kB
import type { Fn } from "@thi.ng/api"; import type { ComponentLike, IComponent, NumOrElement } from "./api.js"; import { Component } from "./component.js"; /** * Simple component wrapper for {@link ComponentLike} promises. When this * component mounts it will `await` the given promise or if it fails, compile * the result of the given (optional) `error` handler as component body. * * @example * ```ts * import { $promise, type ComponentLike } from "@thi.ng/rdom"; * * const prom = Promise.resolve<ComponentLike>( * ["div", {}, "Resolved!"] * ); * * $promise(prom).mount(document.body); * ``` * * @param prom - * @param error - */ export declare const $promise: (prom: Promise<ComponentLike>, error?: Fn<Error, any>) => $Promise; export declare class $Promise extends Component { protected promise: Promise<ComponentLike>; protected error: Fn<Error, any>; inner?: IComponent; constructor(promise: Promise<ComponentLike>, error?: Fn<Error, any>); mount(parent: ParentNode, index: NumOrElement): Promise<Element>; unmount(): Promise<void>; } //# sourceMappingURL=promise.d.ts.map