UNPKG

rvx

Version:

A signal based rendering library

57 lines (56 loc) 2.22 kB
import type { Component } from "../core/types.js"; import { View } from "../core/view.js"; /** * Render content depending on the state of an async function or promise. * * See {@link Async `<Async>`} when using JSX or when named properties are preferred. * * This task is tracked using the current {@link ASYNC async context} if any. It is guaranteed, that the view is updated before the tracked task completes. * * @param source The async function or promise. * + If this is a function, it runs {@link isolate isolated}. * @param component A component to render content when resolved. * + The resolved value is passed as the first argument. * + Nothing is rendered by default. * @param pending A component to render while pending. * + Nothing is rendered by default. * @param rejected A component to render content when rejected. * + The rejected error is passed as the first argument. * + Nothing is rendered by default. */ export declare function nestAsync<T>(source: (() => Promise<T>) | Promise<T>, component?: Component<T>, pending?: Component, rejected?: Component<unknown>): View; /** * Render content depending on the state of an async function or promise. * * See {@link nestAsync} when not using JSX or when positional arguments are preferred. * * This task is tracked using the current {@link ASYNC async context} if any. It is guaranteed, that the view is updated before the tracked task completes. */ export declare function Async<T>(props: { /** * The async function or promise. * * If this is a function, it runs {@link isolate isolated}. */ source: (() => Promise<T>) | Promise<T>; /** * A component to render content when resolved. * * + The resolved value is passed as the first argument. * + Nothing is rendered by default. */ children?: Component<T>; /** * A component render content while pending. * * + Nothing is rendered by default. */ pending?: Component; /** * A component to render content when rejected. * * + The rejected error is passed as the first argument. * + Nothing is rendered by default. */ rejected?: Component<unknown>; }): View;