// Wrapper for a promise that we can await the promise in one case // while allowing an unrelated event to fulfill it elsewhere. export default class Deferred { private promise: Promise; private resolver: (T?) => void; private rejecter: (Error?) => void; constructor() { this.promise = new Promise((resolve, reject) => { this.resolver = resolve; this.rejecter = reject; }); } resolve(value?: T) { this.resolver(value); } reject(error?: Error) { this.rejecter(error); } getPromise(): Promise { return this.promise; } }