I found that it is possible (in ES6 promises while the Promise object is created) to use a multiple decision / rejection that will affect PromiseStatus only once but not affect the execution flow.
var p = new Promise(function(resolve, reject) {
setTimeout(function(){
resolve(1);
console.log('Resolve 1');
}, 50);
setTimeout(function(){
resolve(2);
console.log('Resolve 2');
}, 100);
});
setTimeout(function(){
console.log('Status #1:', p);
}, 10);
setTimeout(function(){
console.log('Status #2:', p);
}, 60);
setTimeout(function(){
console.log('Status #3:', p);
}, 110);
p.then(function(x){
console.log('Value after:', x)
})
In then()the first resolve / reject function, they will affect the flow of execution. So my question is: why does it work like this (function / error)?
PS My env Node 4.1
PPS My conclusion:
Status #1: Promise { <pending> }
Resolve 1
Value after: 1
Status #2: Promise { 1 }
Resolve 2
Status #3: Promise { 1 }
source
share