What RxJS Does
- Observable — lazy stream of values over time
- Operators — 100+ composable transforms (map, filter, merge, concat, switchMap, debounce, throttle)
- Subject — multicast observable, act as source and consumer
- Schedulers — control when subscriptions execute
- Error handling — catchError, retry, retryWhen
- Backpressure — sampling, throttling, buffering strategies
- TypeScript — full typing including operator inference
Architecture
Observables are lazy: they start producing values only when subscribed. Operators are pure functions that return new Observables. Pipeline compiles via the pipe() helper. Schedulers let you move work to microtask/animation frame/etc.
Self-Hosting
Library only.
Key Features
- 100+ operators
- Lazy by default
- Cancellable subscriptions
- Multiple subject types (BehaviorSubject, ReplaySubject, AsyncSubject)
- Schedulers for timing control
- Error handling pipeline
- Tree-shakeable imports
- Full TypeScript types
Comparison
| Library | Model | Learning Curve | Use Case |
|---|---|---|---|
| RxJS | Observable streams | Steep | Complex async, Angular |
| Effect | Fiber-based | Medium | FP-heavy TS projects |
| XState | State machines | Medium | Stateful flows |
| Async iterators | Pull-based | Easy | Simple streams |
| Signals | Reactive primitives | Easy | Fine-grained UI updates |
FAQ
Q: Aren't Promises enough? A: A Promise is a single value; RxJS is a multi-value stream (event sequences, polling, push notifications). Plus RxJS supports unsubscription (Promises don't).
Q: Steep learning curve? A: The hardest part is mastering the 100+ operators. Start with these six — map, filter, switchMap, mergeMap, debounceTime, catchError — which cover most day-to-day use.
Q: Why does Angular lean so heavily on RxJS? A: Angular's HttpClient, Router, Reactive Forms, and EventEmitter all return Observables. RxJS is a first-class citizen of the Angular ecosystem.
Sources & Credits
- Docs: https://rxjs.dev
- GitHub: https://github.com/ReactiveX/rxjs
- License: Apache 2.0