node async.parallel并行执行 报Callback was already called错误怎样解决?
async.parallel([
function (callback) {
self.getNewsByTime().then(function (newsData) {
self.emit('addToLife', newsData, extras, function (err, extras) {
if (err){
next(err, null)
} else {
next(null, extras)
}
});
});
},
function (callback) {
self.getUpdateNewsByTime().then(function (updateNewsData) {
if (updateNewsData.length>0) {
self.emit('updateToLife', updateNewsData, extras, function (err, extras) {
if (err){
next(err, null)
} else {
next(null, extras)
}
});
}
});
},
function (callback) {
self.getDeleteNewsByTime().then(function (deleteNewsData) {
if (deleteNewsData.length>0){
self.emit('deleteFromLife', deleteNewsData, extras, function (err, extras) {
if (err){
next(err, null)
} else {
next(null, extras)
}
});
}
});
}
],
function (err, results) {
console.log(results);
})