ExcelHere
Messages postés12Date d'inscriptionmardi 8 juillet 2014StatutMembreDernière intervention22 août 2014
-
22 août 2014 à 19:13
Bonjour,
Jessaye de comprendre comment utiliser async.series,
pour cela jai pris un petit exemple mais pourquoi rien ne saffiche (mon code s'execute sans erreur, mais aucune sortie dans la console )
merci davance,
var async = require('async');
console.log("top");
function taskFirst(k, v, callback) {
console.log(k, v);
if (error) {
callback(error);
} else {
console.log("tip");
callback(null, result);
}
}
function taskSecond(k, v) {
console.log(k, v);
if (error) {
callback(error);
} else {
console.log("tip");
callback(null, result);
}
}
function run() {
var g1 = "1";
var g2 = "2";
var g3 = "3";
var g4 = "4";
async.series(
[
// Here we need to call next so that async can execute the next function.
// if an error (first parameter is not null) is passed to next, it will directly go to the final callback
function (next) {
taskFirst(g1, g2, next);
},
// runs this only if taskFirst finished without an error
function (next) {
taskSecond(g3, g4, next);
}
],
function(error, result){
console.log("Done");
}
);
}