Skip to content

Instantly share code, notes, and snippets.

@jcoglan
Last active August 29, 2015 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcoglan/9077485 to your computer and use it in GitHub Desktop.
Save jcoglan/9077485 to your computer and use it in GitHub Desktop.
var foo
async.waterfall([
function(cb) {
getThingFromDB("foo", cb)
}, function(_foo, cb) {
foo = _foo
getOtherThingFromDB(foo, "bar", cb)
}, function(bar, cb) {
qux(foo, bar)
}
])
var foo = getThingFromDB("foo")
var bar = foo.then(function(foo) {
return getOtherThingFromDB(foo, "bar")
})
promise.all([foo, bar]).then(function(foo, bar) {
qux(foo, bar)
})
var foo = getThingFromDB("foo"),
bar = getOtherThingFromDB(foo, "bar")
qux(foo, bar)
@mxriverlynn
Copy link

minor update for promises.js

var foo = getThingFromDB("foo")

var bar = foo.then(function(foo) {
  return getOtherThingFromDB(foo, "bar")
})

promise.all([foo, bar]).then(quux)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment