Created
August 12, 2018 12:43
-
-
Save JustinDFuller/c7fb196332a50dcc4b8c5bafa2addb85 to your computer and use it in GitHub Desktop.
Using Promises with promise-funnel
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
const { cork, uncork, wrap } = promiseFunnel() | |
const wrapped = wrap(function () { | |
return 'done!' | |
}) | |
cork() | |
// An unresolved promise is returned | |
const promise = wrapped().then(function (res) { | |
// This happens after uncork() | |
console.log(res) // logs out "done!" after uncork | |
}) | |
uncork() | |
// at this point wrapped.then is called |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment