Last active
December 17, 2018 23:42
-
-
Save willhoney7/ea22248b4c97bce68ad93b436f0cb90b to your computer and use it in GitHub Desktop.
A simple way to do a deferred or inside-out promise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface IDeferredPromise<T> { | |
resolve: (T) => void, | |
reject: (T) => void, | |
promise: Promise<T>, | |
} | |
function DeferredPromise<T>(): IDeferredPromise<T> { | |
this.promise = new Promise<T>((resolve, reject) => { | |
this.resolve = resolve; | |
this.reject = reject; | |
}); | |
return this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment