Skip to content

Instantly share code, notes, and snippets.

@tomgullo
Created August 16, 2013 16:31
Show Gist options
  • Select an option

  • Save tomgullo/6251403 to your computer and use it in GitHub Desktop.

Select an option

Save tomgullo/6251403 to your computer and use it in GitHub Desktop.
async_js_example
$(document).ready(function() {
async.waterfall([
function(next){
setTimeout(function() {
console.log('in this tImeout');
next(null, 'one', 'two');
},
2000);
},
function(arg1, arg2, next){
console.log('arguments ' + arg1);
setTimeout(function() {
console.log('in other tImeout');
next(null, 'three');
//next('whooops', 'error');
},
2000);
},
function(arg1, next){
next(null, arg1);
}
], function (err, result) {
console.log('result ' + result);
console.log('error ' + err);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment