Skip to content

Instantly share code, notes, and snippets.

@draeton
Last active November 5, 2015 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save draeton/633ba4b960aedc172348 to your computer and use it in GitHub Desktop.
Save draeton/633ba4b960aedc172348 to your computer and use it in GitHub Desktop.
Simple deferred
(() => {
'use strict';
function Deferred() {
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
}
let d = new Deferred();
d.promise.then(() => {
console.log('done!');
}).catch(() => {
console.log('error!')
});
d.resolve();
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment