i am trying to understand how to use nimble for flow control with nodejs but I am having trouble understanding how it actually works and there's really no documentation that explains it(that I could find)
For example, take this code from the docs:
_.parallel([
function (callback) {
setTimeout(function () {
console.log('one');
callback();
}, 25);
},
function (callback) {
setTimeout(function () {
console.log('two');
callback();
}, 0);
}
]);
I am having trouble understanding the callback argument that the functions take, what actually gets passed as a callback? The next function in line? If that is the case, then why does the second(and last) function also run callback()? If there is no more functions to run then what is the point of this? Thanks!
I did my own little test and took out the callbacks:
var flow = require('nimble');
flow.parallel([
function() {
setTimeout(function() {
console.log('this happens');
}, 3000);
},
function() {
setTimeout(function() {
console.log('and this happens at the same time');
}, 3000);
}
]);
And the code works the same as if I had callbacks passed in, so now I feel likeI really don't understand what the callback args do.