Skip to content

Instantly share code, notes, and snippets.

@NotWoods
Created June 1, 2016 18:27
Show Gist options
  • Save NotWoods/99629810cc214642b296b65fe6326eb7 to your computer and use it in GitHub Desktop.
Save NotWoods/99629810cc214642b296b65fe6326eb7 to your computer and use it in GitHub Desktop.
/**
* 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