You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

16 lines
371 B

export class Deferred<T = any> {
resolve?: (reason: T | PromiseLike<T>) => void;
reject?: (reason?: any) => void;
promise: Promise<T>;
constructor() {
this.resolve = undefined;
this.reject = undefined;
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
Object.freeze(this);
}
}