【发布时间】:2015-10-20 16:09:15
【问题描述】:
我想使用QPromise进度功能,我有这个代码,我想捕捉进度,当进度为100时,然后解决Promise:
var q = require("q");
var a = function(){
return q.Promise(function(resolve, reject, notify){
var percentage = 0;
var interval = setInterval(function() {
percentage += 20;
notify(percentage);
if (percentage === 100) {
resolve("a");
clearInterval(interval);
}
}, 500);
});
};
var master = a();
master.then(function(res) {
console.log(res);
})
.then(function(progress){
console.log(progress);
});
但我得到这个错误:
Error: Estimate values should be a number of miliseconds in the future
为什么?
【问题讨论】:
标签: javascript node.js promise q