- Promises From The Ground Up • Josh W. Comeau
- ⭐️🎀 JavaScript Visualized: Promises & Async/Await - DEV Community
- JavaScript Visualized - Promise Execution
- Running Promises In Parallel: A Visual Guide | JulesBlom.com
- await vs return vs return await - JakeArchibald.com1
- The gotcha of unhandled promise rejections - JakeArchibald.com
- 14 Linting Rules To Help You Write Asynchronous Code in JavaScript - Maxim Orlov2
- Async/Await without Try/Catch Block in JavaScript3
- Cancelable Async Flows4
- ECMAScript 2024 feature:
Promise.withResolvers()
Footnotes
-- 콜백 → Promise → async/await: 같은 세 단계를 쓰는 세 가지 방법
callback = fetchData (processData (displayData)) -- 안으로 중첩
chain = fetchData >>= processData >>= displayData -- then 으로 옆으로
main = do -- 위에서 아래로
d <- fetchData
p <- processData d
displayData p
-- then 은 모나드의 >>= 와 map 을 한 메서드로 한다
then :: Promise a -> (a -> b | Promise b) -> Promise b
then p f = case f x of
Promise q -> q -- 풀어서 잇는다 (flatMap)
v -> resolve v -- 감싼다 (map)
-- 그래서 Promise (Promise a) 는 만들어지지 않는다 — thenable 도 같은 식으로 푼다