import type { Fn2, Maybe, Path } from "@thi.ng/api"; import type { ISubscribable } from "@thi.ng/rstream"; import { Subscription } from "@thi.ng/rstream/subscription"; import type { IComponent, IMountWithState, NumOrElement } from "./api.js"; /** * Takes an * [`ISubscribable`](https://docs.thi.ng/umbrella/rstream/interfaces/ISubscribable.html) * and creates a simple component wrapper for its reactively produced values. * * @remarks * If given an {@link IMountWithState} component, new stream values are applied * via the `.update()` life cycle value. If given a `tag` and `attribs`, a * corrresponding element wrapper component will be created automatically (using * {@link $wrapText} and stream values will be applied using {@link $text} (aka * setting `el.innerText`). * * @example * ```ts * import { $sub } from "@thi.ng/rdom"; * import { reactive } from "@thi.ng/rstream"; * * const src = reactive(42).map((x) => `value: ${x}`); * * $sub(src, "div", { class: "red" }).mount(document.body); * * src.next(43); * ``` * * @param src - * @param inner - */ export declare function $sub(src: ISubscribable, inner: IMountWithState): IComponent; export declare function $sub(src: ISubscribable, tag: string, attribs?: any): IComponent; /** * Version of {@link $sub} which supports specifying an rstream stream ID for * the resulting subscription (useful for debugging/visualizing the reactive * graph topology). * * @param src * @param inner * @param id */ export declare const $subWithID: (src: ISubscribable, inner: IMountWithState, id: string) => IComponent; export declare class $Sub extends Subscription { protected inner: IMountWithState>; el?: Element; constructor(inner: IMountWithState>, id?: string); mount(parent: ParentNode, index?: NumOrElement): Promise; unmount(): Promise; update(x: T): void; next(x: T): void; } export declare class $SubA extends Subscription { protected comp: IComponent; protected setter: Fn2; protected attr: any; constructor(comp: IComponent, path: Path, id?: string); next(a: any): void; } //# sourceMappingURL=sub.d.ts.map