@pdftron/webviewer-react-toolkit
Version:
A React component library for integrating with PDFTron WebViewer API.
21 lines (20 loc) • 1.09 kB
TypeScript
import { MemoizedPromise } from './memoizedPromise';
/** Either a promise to return a type `T`, or `T` itself. */
export declare type Futurable<T> = Promise<T> | T;
/** Function that returns a promise of `T`, or `T` itself. */
export declare type LazyFuturable<T> = () => Futurable<T>;
/** A promise of `T`, or `T` itself, or a function to return either. */
export declare type FuturableOrLazy<T> = Futurable<T> | LazyFuturable<T>;
/**
* Returns a futurable from a futurable or a lazy futurable. If lazy, will call
* to convert to futurable. Use this at evaluation time only, as any lazy
* futurables will be called at this point.
* @param futurableOrLazy A `Futurable` or a `LazyFuturable`.
*/
export declare function futureableOrLazyToFuturable<T>(futurableOrLazy: FuturableOrLazy<T>): Futurable<T>;
/**
* If the MemoizedPromise is done, will turn into Promise, otherwise will turn
* into lazy Promise
* @param memoizedPromise The memoized promise to convert.
*/
export declare function memoizedPromiseToFuturableOrLazy<T>(memoizedPromise: MemoizedPromise<T>): FuturableOrLazy<T>;