ES6+ Basic5
callback๊ณผ Promise
function add10(a, callback) {
setTimeout(() => callback(a + 10), 100);
}
add10(5, res => {
// ์ฐ์์คํ
add10(res, res => {
log(res);
})
})function add20(a) {
return new Promise(resolve => setTimeout(() => resolve(a+20), 100));
}
add20(5)
// ์ฐ์์คํ
.then(add20)
.then(log);callback๊ณผ Promise์ ์ฐจ์ด
๊ฐ์ผ๋ก์ Promise ํ์ฉ
ํจ์ํฉ์ฑ ๊ด์ ์์์ Promise์ ๋ชจ๋๋
Kleisli Composition ๊ด์ ์์์ Promise
go, pipe, reduce์์ ๋น๋๊ธฐ ์ ์ด
Promise.then์ ์ค์ํ ๊ท์น
์ง์ฐ ํ๊ฐ + Promise - L.map, map, take
Kleisli Composition - L.filter, filter, nop, take
reduce์์ nop์ง์
์ง์ฐ ํ๊ฐ + Promise์ ํจ์จ์ฑ
Last updated