在进行返回 Promise 的异步 WinJS 调用时,Promise 的进度回调函数多久被调用一次?考虑以下代码:
WinJS.xhr({ url: "http://localhost:51299/api/values" }).done(
function complete() {
console.log("complete: " + new Date().getTime());
},
function error() {
},
function progress() {
console.log("progress: " + new Date().getTime());
}
);
当我运行此代码时,我会看到progress: message 每毫秒多次,总体而言,我可能会看到progress: message 在从 xhr 调用中获取所有数据所需的 1-2 秒内 100-200 次。
- 进度函数是否在设定的时间间隔内被调用,如果是,那么该时间间隔是多少?
- 让它频繁运行是性能问题吗?
- 使用某种计时器功能将其限制为较少运行是更好的做法,还是影响微不足道?