I'm learning Node and I'm coming to grips with the asynchronous nature of it. Now I want to use the async library to perform functions in a series. However, every example looks something like:
async.series([
function(callback){
// do some stuff ...
callback(null, 'one');
},
function(callback){
// do some more stuff ...
callback(null, 'two');
}
],
// optional callback
function(err, results){
// results is now equal to ['one', 'two']
});
So it uses anonymous functions. I would prefer to be able to use pre-defined functions (so I can re-use them without copy-pasting the code). So let's say I have a function defined like:
function doStuff(id){
alert(id);
}
How can I add this function to the series above? Also, what to do about the task callback in this case?