async , async series. , , , , ( , -, async.js ):
async.series([
parallel,
function(callBack){ console.log("Trulu"); callBack(null); }
]);
function parallel(callBack){
async.parallel([
function(cb){ print(1); cb(null); },
function(cb){ print(2); cb(null); },
function(cb){ print(3); cb(null); },
function(cb){ print(4); cb(null); },
function(cb){ print(5); cb(null); }
],
function(err) {
if ( err ) {
console.error(err);
return;
}
console.log("Done!");
callBack(null);
}
);
}
, , javascript , . , , , , , , !
Another simpler solution would be to create the last call you want to make after the built-in callback async.parallel:
async.parallel([
function(cb){ print(1); cb(null); },
function(cb){ print(2); cb(null); },
function(cb){ print(3); cb(null); },
function(cb){ print(4); cb(null); },
function(cb){ print(5); cb(null); }
],
function(err) {
if ( err ) {
console.error(err);
return;
}
console.log("Done!");
console.log("Trulu");
}
);
source
share