Last active
August 29, 2015 14:08
-
-
Save chrismeyersfsu/b589f15ac6e196c0d23e to your computer and use it in GitHub Desktop.
async waterfall calldown with multiple arguments
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
// Notice the _.partialRight() call vs. the anonymous function needed in the file below. | |
var async = require('async'); | |
var _ = require('lodash'); | |
async.waterfall([ | |
function (callback) { | |
getBeer(callback); | |
}, function (beer, callback) { | |
getBottleOpener(_.partialRight(callback, beer)); | |
} | |
], function (err, bottleOpener, beer) { | |
openBeer(beer, bottleOpener); | |
}) | |
function getBeer(cb) { | |
cb(null, 'beer'); | |
} | |
function getBottleOpener(cb) { | |
cb(null, 'bottleOpener'); | |
} | |
fucntion openBeer(beer, bottleOpener) { | |
} | |
} |
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
var async = require('async'); | |
async.waterfall([ | |
function (callback) { | |
getBeer(callback); | |
}, function (beer, callback) { | |
getBottleOpener(function(err, bottleOpener) { | |
callback(err, beer, bottleOpener) | |
}) | |
} | |
], function (err, beer, bottleOpener) { | |
openBeer(beer, bottleOpener); | |
}) | |
function getBeer(cb) { | |
cb(null, 'beer'); | |
} | |
function getBottleOpener(cb) { | |
cb(null, 'bottleOpener'); | |
} | |
fucntion openBeer(beer, bottleOpener) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment