var async = require('async');?
?var setTimeoutIds = function(){
?var timeoutIds;?
?var timeoutId;?
?var intervalId;
?timeoutId = setTimeout(function(){?
? ? ? async.waterfall([?
? ? ? ? ? ? ? ?function(cb){?
? ? ? ? ? ? ? ? ? ? ?intervalId = setInterval(function(){?
? ? ? ? ? ? ? ? ? ? ? ? ? console.log('-----intervalId');?
? ? ? ? ? ? ? ? ? ? ?},2000);?
? ? ? ? ? ? ? ? ? ? ?cb();
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? function(cb){?
? ? ? ? ? ? ? ? ? ? ?console.log('intervalId=====',intervalId);?
? ? ? ? ? ? ? ? ? ? ?cb();?
? ? ? ? ? ? ? ? }
? ? ? ? ],function(err,info){?
? ? ? ? ? ? console.log('endendendendend');
? ? ? ?});
?},5000);?
?console.log('timeoutId',timeoutId);?
}
?setTimeoutIds();?
?這樣才能獲取到intervalId?
?如果是這樣用的話?
timeoutId = setTimeout(function(){?
? ? ? ? ?intervalId = setInterval(function(){ },2000);
?},5000);?
只能獲取到timeoutId 而intervalId 是undefined