Progression has been removed as there are composability and chaining issues with APIs that use promise progression handlers. Implementing the common use case of progress bars can be accomplished using a pattern similar to IProgress in C#.
For old code that still uses it, see the progression docs in the deprecated API documentation.
Using jQuery before:
Promise.resolve($.get(...)) .progressed(function() { // ... }) .then(function() { // ... }) .catch(function(e) { // ... })
Using jQuery after:
Promise.resolve($.get(...).progress(function() { // ... })) .then(function() { // ... }) .catch(function(e) { // ... })
Implementing general progress interfaces like in C#:
function returnsPromiseWithProgress(progressHandler) { return doFirstAction().tap(function() { progressHandler(0.33); }).then(doSecondAction).tap(function() { progressHandler(0.66); }).then(doThirdAction).tap(function() { progressHandler(1.00); }); } returnsPromiseWithProgress(function(progress) { ui.progressbar.setWidth((progress * 200) + "px"); // update width on client side }).then(function(value) { // action complete // entire chain is complete. }).catch(function(e) { // error });
Another example using coroutine
:
var doNothing = function() {}; var progressSupportingCoroutine = Promise.coroutine(function* (progress) { progress = typeof progress === "function" ? progress : doNothing; var first = yield getFirstValue(); // 33% done progress(0.33); var second = yield getSecondValue(); progress(0.67); var third = yield getThirdValue(); progress(1); return [first, second, third]; }); var progressConsumingCoroutine = Promise.coroutine(function* () { var allValues = yield progressSupportingCoroutine(function(p) { ui.progressbar.setWidth((p * 200) + "px"); }); var second = allValues[1]; // ... });
© 2013–2017 Petka Antonov
Licensed under the MIT License.
http://bluebirdjs.com/docs/api/progression-migration.html