所有async.js运算符似乎仅用于集合。有没有办法运行这段代码:
async.series([
function (callback) {
TripDao.getTrip(callback);
}],
function done(error, result) {
var trip = result[0];
// things to do with trip
}
);
这样吗?
async.runSingle(function(callback){
TripDao.getTrip(callback);
},
function done(error, trip){
// things to do with trip
}
);
答案 0 :(得分:1)
如果你只需要执行一个函数,为什么不直接传递一个回调?
TripDao.getTrip(function (error, trip) {
// things to do with trip
});