码迷,mamicode.com
首页 > Web开发 > 详细

nodejs串行有关联

时间:2017-08-27 11:55:42      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:settime   log   values   关联   syn   ejs   water   time   fun   

var async = require(‘async‘);

//串行无关联series
//串行有关联waterfall
async.waterfall([
function(cb) {
setTimeout(function(){
console.log(‘111111111‘);
cb(null, 1);
}, 3000);

},
function(param,cb) {
console.log(‘one传来:‘+param);
setTimeout(function(){
console.log(‘222222222‘);
cb(null, 2);
}, 2000);

},
function(param,cb) {
console.log(‘two传来:‘+param);
setTimeout(function(){
console.log(‘333333333‘);
cb(null, 3);
}, 1000);
}
],
function(err, value) {
if(err){
console.log(err);
}
// do somethig with the err or values v1/v2/v3
console.log(value);
}
);

nodejs串行有关联

标签:settime   log   values   关联   syn   ejs   water   time   fun   

原文地址:http://www.cnblogs.com/yu-hailong/p/7439880.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!