3 ms·
That's actually quite a painful way to write async code because the control flow is now inside the functions. That makes it very hard to perform refactoring. M
by mpk 16y ago
That's actually quite a painful way to write async code because the control flow is now inside the functions. That makes it very hard to perform refactoring.
Might I suggest you take a look at my preferred solution for this,
var cb1 = function(callback) {
callback();
}
var cb2 = function(callback) {
req(function() {
callback();
});
}
var cb3 = function(callback) {
req(function() {
callback();
});
}
sequence([
cb1,
cb2,
cb3
]);
The sequencer is a simple lib function you can find at https://github.com/michiel/sequencer-js https://github.com/michiel/sequencer-js or using 'npm install sequencer'