Esta página se muestra en inglés. Una traducción al español está en curso.
ConfigsApr 11, 2026·2 min de lectura

RxJS — Reactive Programming Library for JavaScript

RxJS is a reactive extensions library for JavaScript using Observables for composing asynchronous and event-based programs. 100+ operators for transforming, filtering, and combining streams. The foundation of Angular and many complex UIs.

Introducción

RxJS is the JavaScript implementation of the Reactive Extensions (ReactiveX) API — a library for composing asynchronous and event-based programs using Observable sequences. Originally developed at Microsoft and ported to many languages. In JS land, it powers Angular internals, NgRx, and complex reactive UIs.

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

Discusión

Inicia sesión para unirte a la discusión.
Aún no hay comentarios. Sé el primero en compartir tus ideas.

Activos relacionados