start with promise status implementation

This commit is contained in:
2017-07-27 18:17:37 +02:00
parent b15cdb48a3
commit 31c7e607cc
5 changed files with 9 additions and 37 deletions

View File

@@ -9,14 +9,18 @@ export interface IReject {
(reason?: any): void
}
export type TDeferredStatus = 'pending' | 'fulfilled' | 'rejected'
export class Deferred<T> {
promise: Promise<T>
resolve: IResolve<T>
reject: IReject
constructor() {
status: TDeferredStatus
constructor () {
this.promise = new Promise<T>((resolve, reject) => {
this.resolve = resolve
this.reject = reject
this.status = 'pending'
})
}
}