Last active
November 5, 2015 19:28
-
-
Save draeton/633ba4b960aedc172348 to your computer and use it in GitHub Desktop.
Simple deferred
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
(() => { | |
'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