async.map(list, function(object, callback) {
async.series([
function(callback) {
console.log("1");
var booltest = false;
// assuming some logic is performed that may or may not change booltest
if(booltest) {
// finish this current function, move on to next function in series
} else {
// stop here and just die, dont move on to the next function in the series
}
callback(null, 'one');
},
function(callback) {
console.log("2");
callback(null, 'two');
}
],
function(err, done){
});
});
有沒有一些方法,例如,如果功能1,如果booltest計算結果爲真,不轉移到輸出「2」接下來的功能?有沒有辦法停止在nodejs中使用異步執行系列的下一個函數?
'返回回調( '停止')'會停止你的一系列的執行和異步調用回調函數與'ERR =「stop''。 – 2013-05-07 16:00:04
你能舉個例子嗎?我似乎不知道該變量(標誌)會在哪裏出現,假設booltest必須在處理列表中的元素開始處重置其自身。 – Rolando 2013-05-07 16:00:20