A learn-by-doing tour of RxJS in 16 ticks, from "what is an Observable" to writing a
production-grade backoffWithJitter retry operator. Each tick is a small directory: a runnable example, an exercise to solve, and a short doc. The goal isn't to memorize operators — it's to build the mental model:
laziness, hot vs cold, flattening, error propagation, teardown, scheduling.
npm install
npm run tick1:example # run the concept demo … tickN:example
npm run tick1:task # run the exercise / your solution … tickN:task
npm run typecheck # tsc --noEmit across all ticksRuntime: Node + tsx (no build step). Strict TypeScript.
| # | Topic | Key idea |
|---|---|---|
| 1 | Observable, Observer, Subscription | lazy streams; next/error/complete |
| 2 | Creation + pipe/map/filter |
of/from; operators are stream→stream |
| 3 | Async time — interval/take/tap |
take completes; operator order matters |
| 4 | Higher-order — switchMap/mergeMap |
flattening; cancel-latest vs keep-all |
| 5 | Subjects & hot vs cold | multicast; BehaviorSubject replay |
| 6 | Combination — merge/combineLatest |
react to any; wait-for-all gotcha |
| 7 | withLatestFrom & zip |
trigger+context vs index pairing |
| 8 | Error handling — catchError/retry |
errors are terminal; blast radius |
| 9 | Marble testing | virtual time; map preserves timing |
| 10 | shareReplay |
fetch once, share; refCount leak |
| 11 | scan vs reduce |
running vs final; reduce needs completion |
| 12 | debounceTime + distinctUntilChanged |
the type-ahead recipe |
| 13 | takeUntil |
teardown signal; finalize vs tap |
| 14 | Custom operators | compose vs from-scratch; return the subscription |
| 15 | Schedulers | sync default; micro- vs macrotask |
| 16 | Capstone — backoffWithJitter() |
reusable retry operator with jitter |
CHEATSHEET.md is the one-page recap of all 16.
Each tickN/ directory holds three files:
example.ts— a small, runnable demo of the concept, with comments. Runnpm run tickN:example.task.ts— the exercise (a// YOUR TASKblock). In thedocscommit it's a scaffold ending in// write your code here; in thefeatcommit it holds the worked answer plus a// === Review ===comment on why it works. Runnpm run tickN:task.tickN.md— the prose doc: concept · example · task · key takeaways.
Example and task are separate programs, so their console output never interleaves.
The git history is meant to be replayable as a course. Conventional-commit prefixes, and two commits per tick:
docs(tickN): … — concept, example, task scaffoldAddstickN/example.ts(the demo),tickN/task.ts(task +// write your code here),tickN/tickN.md, and thetickN:example/tickN:tasknpm scripts. Runnpm run tickN:taskto attempt it.feat(tickN): … — solution + cheatsheetFillstickN/task.tswith the worked solution (=== Review ===notes) and appends that tick's section toCHEATSHEET.md(header range growsTicks 1–N).
Plus one chore: setup commit at the root (deps, base npm scripts, strict tsconfig, MIT license).
So the log reads top-to-bottom as: set up → learn tick 1 (read doc, run example, try task, see solution) →
… → tick 16. git checkout <docs-commit> to practice; git diff <docs>..<feat> to compare your
answer with the worked one.
- Runnable over abstract — every concept is a program you can execute and modify, not a paragraph. Async behavior (timing, cancellation, scheduling) only really lands when you watch it.
- Strict TypeScript — types catch the classic mistakes (e.g. calling a
numbermethod on astring) before runtime, which is half the lesson in several ticks. - One concept per tick — small enough to hold in your head; the cheatsheet stitches them together.