Last active
November 19, 2016 06:08
-
-
Save choru-k/bbc08b8f217d50e72e4873dab056ed3f to your computer and use it in GitHub Desktop.
promise chain test 1
This file contains hidden or 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
var _promise1 = function (param) { | |
return new Promise(function (resolve, reject) { | |
setTimeout(function () { | |
resolve("ok1"); | |
}, 3000); | |
}); | |
}; | |
var _promise2 = function (param) { | |
return new Promise(function (resolve, reject) { | |
setTimeout(function () { | |
resolve("ok2"); | |
}, 3000); | |
}); | |
}; | |
_promise1(true) | |
.then(function (text) { | |
_promise2(true) | |
.then(function (text) { | |
console.log(text); | |
}) | |
console.log(text); | |
}).then(function() { | |
console.log('ok3') | |
}); | |
// result | |
// ok1 - 3second later | |
// ok3 - 3second later | |
// ok2 - 6second later |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
여기서 then뒤에는 아에 return 이 없잖아