Created
March 16, 2018 22:14
-
-
Save idmontie/ff525d69daf2c0bfabe2ff57aa365385 to your computer and use it in GitHub Desktop.
Promises with thenable objects
This file contains 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
function thenable(value) { | |
return { | |
then: function (onfulfill, onreject) { | |
onfulfill(value); | |
}; | |
}; | |
} | |
const promise = Promise.resolve(thenable('voila!')); | |
promise.then(function(result) { | |
console.log(result); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment