异步:运行 单一功能
Async: run single function
所有 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
}
);
如果你只需要执行一个函数,为什么不直接传递一个回调函数呢?
TripDao.getTrip(function (error, trip) {
// things to do with trip
});
所有 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
}
);
如果你只需要执行一个函数,为什么不直接传递一个回调函数呢?
TripDao.getTrip(function (error, trip) {
// things to do with trip
});