@pdftron/webviewer-react-toolkit
Version:
A React component library for integrating with PDFTron WebViewer API.
25 lines (24 loc) • 923 B
TypeScript
import { FuturableOrLazy } from './futurable';
export interface MemoizeOptions {
/**
* If true, will immediately process the input, even if it's a lazy promise (
* a function to retrieve a promise).
*/
preprocess?: boolean;
}
/**
* This class is responsible for wrapping tasks in a promise that won't be
* executed until the result is actually required. Calling .get() on the class
* will start the task, and resolve with the result. If the task has already
* been executed once, it will resolve immediatly with the last result.
*/
export declare class MemoizedPromise<T> {
private _futurableOrLazy;
private _result?;
private _done;
constructor(futurableOrLazy: MemoizedPromise<T> | FuturableOrLazy<T>, options?: MemoizeOptions);
/** Is true if the value is memoized. */
get done(): boolean;
/** Resolves with a promise for the value. */
get: () => Promise<T>;
}