Created
January 19, 2016 05:24
-
-
Save dineshsprabu/3c27c80b0ec8563bf497 to your computer and use it in GitHub Desktop.
NodeJS Async Series Example
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"); | |
//series calls the final callback function on every successful execution of the function in the list. | |
async.series([ | |
function(callback) { | |
setTimeout(function() { | |
console.log("Task 1"); | |
callback(null, 1); | |
}, 300); | |
}, | |
function(callback) { | |
setTimeout(function() { | |
console.log("Task 2"); | |
callback(null, 2); | |
}, 200); | |
}, | |
function(callback) { | |
setTimeout(function() { | |
console.log("Task 3"); | |
callback(null, 3); | |
}, 100); | |
} | |
], function(error, results) { | |
console.log(results); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment