UNPKG

@tempots/ui

Version:

Provides a higher level of renderables to help fast development with Tempo.

35 lines (34 loc) 1.2 kB
import { TNode, Signal, Value, Renderable } from '@tempots/dom'; import { Result } from '@tempots/std'; /** * Represents the signal for a result. * * @typeParam T - The type of the success value. * @typeParam E - The type of the error value. * @public */ export type ResultViewOptions<T, E> = { /** * The function to render the view when the computation succeeds. * @param value - The signal for the success value. * @returns The rendered view. */ success: (value: Signal<T>) => TNode; /** * The function to render the view when the computation fails. * @param error - The signal for the error value. * @returns The rendered view. */ failure?: (error: Signal<E>) => TNode; }; /** * Renders a view based on the result of a computation. * * @typeParam T - The type of the success value. * @typeParam E - The type of the error value. * @param result - The result of the computation. * @param options - The options for rendering the view. * @returns The rendered view. * @public */ export declare const ResultView: <T, E>(result: Value<Result<T, E>>, options: ResultViewOptions<T, E> | ((value: Signal<T>) => TNode)) => Renderable;