import type { ReadableSignal } from '@amadeus-it-group/tansu'; /** * Represents the result of a promise that is still pending. */ export interface PromisePendingResult { /** Pending status */ status: 'pending'; } /** * A constant representing a pending promise result. */ export declare const promisePending: PromisePendingResult; /** * Represents the state of a promise, which can be either fulfilled, rejected, or pending. * * @template T - The type of the value promised */ export type PromiseState = PromiseFulfilledResult | PromiseRejectedResult | PromisePendingResult; /** * Create a readable promise state store from a promise. * * The state of the returned store tracks the state of the promise and the resolved value or rejection reason. * * @param value - the promise * @returns the readable promise state store */ export declare const promiseStateStore: (value: T) => ReadableSignal>>>; /** * Create a readable promise state store from a promise store. * * @param promiseStore$ - the promise store * @returns the readable promise state store */ export declare const promiseStoreToPromiseStateStore: (promiseStore$: ReadableSignal) => ReadableSignal>>; /** * Create a value store from a promise state store * * The returned value store is only updated if the promise is fulfilled. * * @param store$ - the promise state store * @param initialValue - the initial value of the returned value store * @param equal - an equal function to compare values * @returns the value store */ export declare const promiseStateStoreToValueStore: (store$: ReadableSignal>, initialValue: T, equal?: (a: T, b: T) => boolean) => ReadableSignal; /** * Create a value store from a promise store * * The returned value store is only updated if the promise is fulfilled. * * @param promiseStore$ - the promise store * @param initialValue - the initial value of the returned value store * @param equal - an equal function to compare values * @returns the value store */ export declare const promiseStoreToValueStore: (promiseStore$: ReadableSignal, initialValue: Awaited, equal?: (a: Awaited, b: Awaited) => boolean) => ReadableSignal>; /** * Create a promise from a readable store and a fulfilled condition function. * * The promise is fulfilled when the state of the store respects the provided condition function. * * @param store - the readable store * @param condition - the condition function * @returns the promise and an unsubscribe function */ export declare const promiseFromStore: (store: ReadableSignal, condition?: (value: T) => boolean) => { promise: Promise; unsubscribe(): void; }; /** * Create a promise from an HTML element event. * * @param element - the event target * @param event - the event to listen to * @returns the promise and an unsubscribe function */ export declare const promiseFromEvent: (element: EventTarget, event: string) => { promise: Promise; unsubscribe(): void; }; /** * Create a promise that resolves once a timeout has been reached. * * @param delay - the delay in milli seconds * @returns a promise and an unsubscribe function */ export declare const promiseFromTimeout: (delay: number) => { promise: Promise; unsubscribe(): void; }; /** * Utility method to create a promise with resolve * @returns a promise with resolve */ export declare const promiseWithResolve: () => { promise: Promise; resolve: (value: void | Promise) => void; };