Skip to content

Instantly share code, notes, and snippets.

@JustinDFuller
Created August 12, 2018 12:43
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 JustinDFuller/c7fb196332a50dcc4b8c5bafa2addb85 to your computer and use it in GitHub Desktop.
Save JustinDFuller/c7fb196332a50dcc4b8c5bafa2addb85 to your computer and use it in GitHub Desktop.
Using Promises with promise-funnel
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