grafana/public/app/core/utils/deferred.ts
Ashley Harrison d2a70bc42d
Chore: more any/type assertion improvements (#57450)
* more friday any/type assertion improvements

* Apply suggestions from code review

Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>

* Update public/app/angular/promiseToDigest.test.ts

Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>

Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
2022-10-25 11:04:35 +02:00

17 lines
375 B
TypeScript

export class Deferred<T = unknown> {
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);
}
}