Deferred Class
Package: @esfx/async-deferred
Encapsulates a Promise and exposes its resolve and reject callbacks.
Declaration
export declare class Deferred<T>
Constructors
constructor()
Initializes a new instance of the Deferred class.
Declaration
constructor();
Properties
callback
Gets a NodeJS-style callback that can be used to resolve or reject the promise.
Declaration
get callback(): T extends void ? (err: Error | null | undefined) => void : (err: Error | null | undefined, value: T) => void;
Property Value
T extends void ? (err: Error | null | undefined) => void : (err: Error | null | undefined, value: T) => void
promise
Gets the promise.
Declaration
get promise(): Promise<T>;
Property Value
Promise<T>
reject
Gets the callback used to reject the promise.
Declaration
get reject(): (reason: any) => void;
Property Value
(reason: any) => void
resolve
Gets the callback used to resolve the promise.
Declaration
get resolve(): (value: T | PromiseLike<T>) => void;
Property Value
(value: T | PromiseLike<T>) => void
Methods
createCallback(selector)
Creates a NodeJS-style callback that can be used to resolve or reject the promise with multiple values.
Declaration
createCallback<A extends any[]>(selector: (...args: A) => T): (err: Error | null | undefined, ...args: A) => void;
Type Parameters
- A
Parameters
- selector
- (...args: A) => T
Returns
(err: Error | null | undefined, ...args: A) => void