What causes an error in RSVP Deferred when the promise is called twice?
There appears to be a distinction between
deferred.promise.then().finally()
and deferred.promise.then(); deferred.promise.finally()
. Why is this?
RSVP.on('error', function(reason) {
console.log('Error: ' + reason);
});
var deferred = RSVP.defer();
var deferred2 = RSVP.defer();
var deferred3 = RSVP.defer();
var promise3 = deferred3.promise;
deferred.promise.then(function() {
console.log('Resolved');
}, function() {
console.log('Rejected');
}).finally(function() {
console.log('Finally');
});
deferred2.promise.then(function() {
console.log('Resolved2');
}, function() {
console.log('Rejected2');
});
deferred2.promise.finally(function() {
console.log('Finally2');
});
promise3 = promise3.then(function() {
console.log('Resolved3');
}, function() {
console.log('Rejected');
});
promise3.finally(function() {
console.log('Finally3');
});
deferred.reject('Reject!');
deferred2.reject('Reject2!');
deferred3.reject('Reject3!');
<script src="https://cdnjs.cloudflare.com/ajax/libs/rsvp/4.8.1/rsvp.js"></script>
UPDATE: I have identified how to resolve the problem. Check out the Deferred3 part in the code.