var promise1 = new Promise(function(resolve, reject) {
setTimeout(function() {
console.log("I am resolving");
resolve('foo');
}, 300);
console.log("Just inited me, not yet resolved");
});
var pro2 = Promise.resolve().then((val) => {
console.log("Calling promise");
return promise1.then(function(val1) {
console.log("Promise was resolved and returned value");
return val1 ;
});
});
pro2.then((val) => {
console.log(val);
});
Note: the then will be called right after the resolve is invoked
No comments:
Post a Comment