UNPKG

834 BTypeScriptView Raw
1/**
2 * A class which wraps a promise into a delegate object.
3 *
4 * #### Notes
5 * This class is useful when the logic to resolve or reject a promise
6 * cannot be defined at the point where the promise is created.
7 */
8export declare class PromiseDelegate<T> {
9 /**
10 * Construct a new promise delegate.
11 */
12 constructor();
13 /**
14 * The promise wrapped by the delegate.
15 */
16 readonly promise: Promise<T>;
17 /**
18 * Resolve the wrapped promise with the given value.
19 *
20 * @param value - The value to use for resolving the promise.
21 */
22 resolve(value: T | PromiseLike<T>): void;
23 /**
24 * Reject the wrapped promise with the given value.
25 *
26 * @reason - The reason for rejecting the promise.
27 */
28 reject(reason: unknown): void;
29 private _resolve;
30 private _reject;
31}