Created
June 1, 2016 18:27
-
-
Save NotWoods/99629810cc214642b296b65fe6326eb7 to your computer and use it in GitHub Desktop.
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
/** | |
* Creates a promise that can be resolved from the outside. | |
* @property {function} resolve - resolves the promise | |
* @property {function} reject - rejects the promise | |
*/ | |
class Deferred extends Promise { | |
constructor() { | |
var _resolve, _reject; | |
super((resolve, reject) => { | |
_resolve = resolve; | |
_reject = reject; | |
}) | |
this.resolve = _resolve; | |
this.reject = _reject; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment