Commit 6a331465 authored by Tristan Cavelier's avatar Tristan Cavelier

Promise notify propagates to all then progress

parent db7c70a2
...@@ -519,7 +519,23 @@ Promise.prototype.then = function (onSuccess, onError, onProgress) { ...@@ -519,7 +519,23 @@ Promise.prototype.then = function (onSuccess, onError, onProgress) {
}); });
} }
if (typeof onProgress === 'function') { if (typeof onProgress === 'function') {
this._onProgress.push(onProgress); this._onProgress.push(function () {
var result;
try {
result = onProgress.apply(that, arguments);
if (result === undefined) {
resolver.notify.apply(that, arguments);
} else {
resolver.notify(result);
}
} catch (e) {
resolver.notify.apply(that, arguments);
}
});
} else {
this._onProgress.push(function () {
resolver.notify.apply(resolver, arguments);
});
} }
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment