From 6a33146526322745f981641580c4aa13268cb0db Mon Sep 17 00:00:00 2001
From: Tristan Cavelier <tristan.cavelier@tiolive.com>
Date: Thu, 5 Sep 2013 11:06:08 +0200
Subject: [PATCH] Promise notify propagates to all then progress

---
 src/jio/core/Promise.js | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/jio/core/Promise.js b/src/jio/core/Promise.js
index a3c7b22..2d90243 100644
--- a/src/jio/core/Promise.js
+++ b/src/jio/core/Promise.js
@@ -519,7 +519,23 @@ Promise.prototype.then = function (onSuccess, onError, onProgress) {
       });
     }
     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;
   }
-- 
2.30.9