【发布时间】:2012-09-09 19:21:52
【问题描述】:
我在理解如何使用 "q" (https://github.com/kriskowal/q) 一个用于 javascript 的承诺库时遇到了一些问题:
var delayOne = function() {
setTimeout(function() {
return 'hi';
}, 100);
};
var delayTwo = function(preValue) {
setTimeout(function() {
return preValue + ' my name';
}, 200);
};
var delayThree = function(preValue) {
setTimeout(function() {
return preValue + ' is bodo';
}, 300);
};
var delayFour = function(preValue) {
setTimeout(function() {
console.log(preValue);
}, 400);
};
Q.fcall(delayOne).then(delayTwo).then(delayThree).then(delayFour).end();
这只会返回未定义...
【问题讨论】:
标签: javascript asynchronous callback promise q