Created
April 26, 2013 13:43
-
-
Save stash/5467459 to your computer and use it in GitHub Desktop.
async.waterfall gotchas
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
var async = require('async'); | |
/*jshint noarg:false */ | |
function first(next) { | |
console.log('first', arguments); | |
next(); // no params = nothing in next step | |
} | |
function second(next) { | |
console.log('second', arguments); | |
next(null); // no "result" params = nothing in next step | |
} | |
function third(next) { | |
console.log('third', arguments); | |
next(null,null); // explicit null param = one parameter in next step | |
} | |
function fourth(isNull, next) { | |
console.log('fourth', arguments); | |
next(null,'all done'); | |
} | |
async.waterfall([ | |
first, | |
second, | |
third, | |
fourth | |
], function(err,lastResult) { | |
console.log('finally', arguments); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment