element-vir
Version:
Heroic. Reactive. Declarative. Type safe. Web components without compromise.
46 lines (45 loc) • 2.93 kB
TypeScript
import { type AsyncProp } from './async-prop.js';
/**
* Given a {@link AsyncProp} instance, call and return the output of the `resolutionRender` parameter
* once the {@link AsyncProp} has been resolved, call and return the output of the `errorRender`
* parameter if the {@link AsyncProp} errored out, return the `fallback` parameter in all other
* cases.
*
* This is the overload for when `resolutionRender` and `errorRender` are both provided.
*
* @category Async
*/
export declare function renderAsync<T, FallbackResult, ResolutionRenderResult = never, ErrorRenderResult = never>(asyncProp: Pick<AsyncProp<T, any>, 'value'>, fallback: FallbackResult, resolutionRender: (resolved: Awaited<T>) => ResolutionRenderResult, errorRender: (error: Error) => ErrorRenderResult): FallbackResult | ResolutionRenderResult | ErrorRenderResult;
/**
* Given a {@link AsyncProp} instance, call and return the output of the `resolutionRender` parameter
* once the {@link AsyncProp} has been resolved, call and return the output of the `errorRender`
* parameter if the {@link AsyncProp} errored out, return the `fallback` parameter in all other
* cases.
*
* This is the overload for when `resolutionRender` is provided but `errorRender` is not.
*
* @category Async
*/
export declare function renderAsync<T, FallbackResult, ResolutionRenderResult = never>(asyncProp: Pick<AsyncProp<T, any>, 'value'>, fallback: FallbackResult, resolutionRender: (resolved: Awaited<T>) => ResolutionRenderResult, errorRender?: undefined): FallbackResult | ResolutionRenderResult | string;
/**
* Given a {@link AsyncProp} instance, call and return the output of the `resolutionRender` parameter
* once the {@link AsyncProp} has been resolved, call and return the output of the `errorRender`
* parameter if the {@link AsyncProp} errored out, return the `fallback` parameter in all other
* cases.
*
* This is the overload for when `resolutionRender` is not provided but `errorRender` is.
*
* @category Async
*/
export declare function renderAsync<T, FallbackResult, ErrorRenderResult = never>(asyncProp: Pick<AsyncProp<T, any>, 'value'>, fallback: FallbackResult, resolutionRender: undefined, errorRender: (error: Error) => ErrorRenderResult): FallbackResult | Awaited<T> | ErrorRenderResult;
/**
* Given a {@link AsyncProp} instance, call and return the output of the `resolutionRender` parameter
* once the {@link AsyncProp} has been resolved, call and return the output of the `errorRender`
* parameter if the {@link AsyncProp} errored out, return the `fallback` parameter in all other
* cases.
*
* This is the overload for when neither `resolutionRender` or `errorRender` are provided.
*
* @category Async
*/
export declare function renderAsync<T, FallbackResult>(asyncProp: Pick<AsyncProp<T, any>, 'value'>, fallback: FallbackResult, resolutionRender?: undefined, errorRender?: undefined): FallbackResult | Awaited<T> | string;