Created
July 2, 2015 03:05
-
-
Save Jxck/129ed81ad6bce4710758 to your computer and use it in GitHub Desktop.
Promise.chain()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Promise(function (resolve) { | |
var pp = new Promise(function(r) { | |
setTimeout(function() { | |
r('aa'); | |
}, 100); | |
}); | |
setTimeout(function() { | |
resolve(pp); | |
}, 100); | |
}).chain(function(p) { | |
// then だと p も resolve された結果になる | |
console.log(p); | |
p.then(function(v) { | |
console.log(v); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment