Created
November 17, 2016 15:09
-
-
Save choru-k/ecf2a15cd1afa8ab10047274bc4c914d to your computer and use it in GitHub Desktop.
promise chain test 2
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) { | |
console.log(text); | |
return _promise2(true) | |
}).then(function (text) { | |
console.log(text); | |
}).then(function() { | |
console.log('ok3') | |
}); | |
// result | |
// ok1 - 3second later | |
// ok2 - 6second later | |
// ok3 - 6second later |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
_promise1
실행_promise2(true)
를 실행하여 promise 객체를 넘겨줌즉 위의 코드는
와 다를바가 없다