Ser*_*giy 2 waterfall node.js async.js
我正在使用瀑布方法的异步模块.
async.waterfall([
function(callback) {
...
callback(err);
},
function(result, callback) {
console.log("This function should not be executed");
}
],
function(err) {
if (err) {
next(err);
return;
}
}
);
Run Code Online (Sandbox Code Playgroud)
但第二个功能总是执行.怎么预防呢?
尝试添加一个 return
async.waterfall([
function(callback) {
...
return callback(err); //note return here
},
function(result, callback) {
console.log("This function should not be executed");
}
],
function(err) {
if (err) {
next(err);
return;
}
}
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4460 次 |
| 最近记录: |