Skip to content

Instantly share code, notes, and snippets.

@Jxck
Created July 2, 2015 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jxck/129ed81ad6bce4710758 to your computer and use it in GitHub Desktop.
Save Jxck/129ed81ad6bce4710758 to your computer and use it in GitHub Desktop.
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