JavaScript: Async
The half that is about time
Everything else in a program happens where you put it. This does not: a line runs when a queue gets to it, and the queue has rules. Learn them until the order is obvious, then build what uses them — a runner that bounds every call, limits how many run at once, and stops the moment it is told to.
- Modules
- 6
- Drills
- 11
- Build steps
- 5
- Time
- ~6h
Walk out able to
Predict the exact print order of any mix of sync code, promise reactions and timers — and cancel work that is no longer wanted.
What you work through
Callbacks and promises
The contract nothing enforced, and what replaced it.
await, and what it cost
Suspension, concurrency, and the latency you stopped paying.
Sync, microtask, macrotask
The checkpoint rule, drilled until the order is obvious.
Failure and cancellation
Rejections that stay caught, and work that actually stops.
The pitch
What you practise, and what you leave with
A dependency-free job runner over a deterministic offline service: bounded, limited, retried, and provably stopped when it is told to stop.
You will practise
- Callback contracts, chains and async syntax
- Combinators, and what they do not cancel
- Sync, microtask and timer ordering
- Rejections, retries and abort signals
Afterwards you can
- Order a mixed program first time
- Cost a waterfall before writing it
- Keep every rejection attached to a handler
- Cancel in-flight work and prove it
Modules
6 modules, 31 items
Lessons explain one idea. Drills repeat it until it sticks. Build steps make something that exists afterwards.
- 1
What a callback costs
~48 minName the guarantee a callback API is breaking, and hold the result yourself instead.
- LessonWhy time is the hard half6 min
- LessonWhat you gave away with the callback7 min
- LessonHold the result yourself7 min
- DrillName the guarantee it broke12 min
- Build stepWrap a callback API in a promise16 min
- 2
A value that has not arrived
~45 minSay what a chain ends with, and pick the combinator a requirement actually names.
- LessonWhat a link hands to the next7 min
- LessonThe one-word bug in a chain6 min
- LessonA catch resumes the chain6 min
- DrillSay what the chain ends with13 min
- DrillPick the combinator13 min
- 3
Write it as if it were sync
~1hRead an async function as a suspension, and stop paying double for independent calls.
- LessonAn async function is a suspension7 min
- LessonA waterfall nobody asked for7 min
- LessonConcurrent is not parallel6 min
- DrillCost the awaits12 min
- DrillGet the syntax into your fingers14 min
- Build stepUnpick a request waterfall16 min
- 4
Sync, microtask, macrotask
~44 minPredict the print order of any mix of synchronous code, reactions and timers.
- LessonOne loop, two queues8 min
- LessonThe checkpoint drains to empty8 min
- DrillPut the output in order14 min
- Build stepWatch one pass of the loop14 min
- 5
Errors that cross an await
~51 minKeep a rejection attached to a handler, wherever the await boundary put it.
- LessonWhere a rejection actually lands7 min
- LessonThe three ways it goes quiet8 min
- DrillSay which handler catches it12 min
- DrillSay what to do with the status12 min
- DrillDecide whether to send it again12 min
- 6
Stop work you no longer want
~1hBound every call, cancel what is superseded, and know what abort does not stop.
- LessonWhat abort actually stops7 min
- LessonIt stops only what is watching8 min
- DrillSay what happens after abort12 min
- DrillCost a retry policy12 min
- Build stepBuild a runner that survives a bad day26 min
- Build stepProve it stops when told22 min
More in Languages
Keep going
Python Foundations
Read a program before you run it. Then write one worth showing.
Foundational~6h8 modules
Python Fluency
Choose the shape before you type. Then say it in one line.
Intermediate~5h7 modules
Python Confidence
Somebody else wrote it. Find out whether it works.
Advanced~7h7 modules
Python Craft
It works. Now make it somebody else's.
Advanced~10h7 modules
Nothing here runs when you wrote it.
The first item is free. ~6h of focused work, at your own pace.
Intermediate~6h6 modules