UNPKG

async-ref

Version:

Async ref objects for React. A tiny bridge between React.useSyncExternalStore and React.Suspense.

21 lines (19 loc) 913 B
declare type Notify = () => void; declare type IAsyncMutableRefObject<T> = { current: T; resolve(value: T): void; reject(error: Error): void; }; declare class AsyncMutableRefObject<T> implements IAsyncMutableRefObject<T>, PromiseLike<T> { #private; constructor(notify?: Notify); get current(): T; set current(value: T); then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>; resolve(value: T): AsyncMutableRefObject<T>; reject(error: Error): AsyncMutableRefObject<T>; freeze(): AsyncMutableRefObject<T>; isFrozen(): boolean; } declare const createAsyncRef: <T>(notify?: Notify) => AsyncMutableRefObject<T>; export { IAsyncMutableRefObject as AsyncMutableRefObject, createAsyncRef };