Commit 41eba17a authored by Tristan Cavelier's avatar Tristan Cavelier

notifications are not propagated to parents fixed

parent fdaaddad
...@@ -203,6 +203,11 @@ function handleThenable(promise, value) { ...@@ -203,6 +203,11 @@ function handleThenable(promise, value) {
then = value.then; then = value.then;
if (isFunction(then)) { if (isFunction(then)) {
if (isFunction(value.on)) {
value.on('promise:notified', function (event) {
notify(promise, event.detail);
});
}
promise.on('promise:cancelled', function(event) { promise.on('promise:cancelled', function(event) {
if (isFunction(value.cancel)) { if (isFunction(value.cancel)) {
value.cancel(); value.cancel();
......
...@@ -236,6 +236,31 @@ describe("RSVP extensions", function() { ...@@ -236,6 +236,31 @@ describe("RSVP extensions", function() {
}); });
}); });
it('notify should propagate to parent `then`', function (done) {
var i = 0, responses = [];
new RSVP.Promise(function (resolve) {
resolve();
}).then(function () {
return new RSVP.Promise(function (resolve, reject, notify) {
notify(1);
notify(2);
resolve(3);
});
}).then(function (answer) {
responses.push(answer);
}, null, function (notification) {
responses.push(notification);
});
setTimeout(function () {
assert(responses[0] === 1, "Notified once");
assert(responses[1] === 2, "Notified twice");
assert(responses[2] === 3, "Fulfilled after notifications");
done();
}, 50);
});
describe('assimilation', function() { describe('assimilation', function() {
it('should assimilate if `resolve` is called with a fulfilled promise', function(done) { it('should assimilate if `resolve` is called with a fulfilled promise', function(done) {
var originalPromise = new RSVP.Promise(function(resolve) { resolve('original value'); }); var originalPromise = new RSVP.Promise(function(resolve) { resolve('original value'); });
......
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