Create a gist now

Instantly share code, notes, and snippets.

Promise.chain()
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