Re-writing mariusa's example from https://github.com/caolan/async/issues/114
async.parallel({ | |
a: function(callback) { | |
fs.readFile('a.html', 'utf8', function(err, a) { | |
if (err) callback(err); | |
console.log('read a'); | |
callback(null, a); | |
}); | |
}, | |
b: function(callback) { | |
fs.readFile('b.html', 'utf8', function(err, b) { | |
if (err) callback(err); | |
console.log('read b'); | |
callback(null, b); | |
}); | |
} | |
}, function (err, results) { | |
console.log('a:' + results.a); | |
console.log('b:' + results.b); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
You know this is incorrect right? The callback would get called twice in the parallel functions. Either place the second callback in an else block or use
if (err) **return** callback(err);