{"library":"rxjs","title":"RxJS: Reactive Extensions for JavaScript","description":"RxJS (Reactive Extensions for JavaScript) is a powerful library for composing asynchronous and event-based programs using observable sequences. It provides a declarative paradigm for managing complex asynchronous operations, leading to more readable and maintainable code. The current stable version is 7.8.2, with active development progressing towards version 8, which is currently in alpha and introduces further optimizations and breaking changes. RxJS utilizes a \"push\" model, allowing data producers to emit multiple values over time to consumers, a fundamental difference from the \"pull\" model of iterators. Its key differentiators include a rich array of operators for transforming, filtering, and combining data streams, robust TypeScript support, and a strong emphasis on performance and modularity. This makes it a preferred choice over traditional callback-based or Promise-based approaches for intricate asynchronous scenarios, forming a core component in many modern web frameworks and applications that leverage reactive programming.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install rxjs"],"cli":null},"imports":["import { Observable } from 'rxjs';","import { of, map, filter } from 'rxjs';","import { Subject } from 'rxjs';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { range, filter, map, Observable } from 'rxjs';\n\n// Create an observable that emits numbers from 1 to 200\nconst source$: Observable<number> = range(1, 200);\n\n// Pipe operators to transform the stream\nconst processedStream$ = source$.pipe(\n  filter(x => x % 2 === 1), // Keep only odd numbers\n  map(x => x + x)           // Double each odd number\n);\n\n// Subscribe to the stream to receive values and log them\nconsole.log('Starting stream subscription...');\nprocessedStream$.subscribe({\n  next: x => console.log(`Received: ${x}`), // Log each emitted value\n  error: err => console.error('An error occurred:', err), // Handle errors\n  complete: () => console.log('Stream completed.') // Log when the stream finishes\n});\n\n// Example of a simple timer to show asynchronous nature\nimport { timer } from 'rxjs';\n\ntimer(2000, 1000).subscribe(val => console.log(`Timer tick: ${val}`));","lang":"typescript","description":"Demonstrates creating an Observable, applying pipeable operators (`filter`, `map`), and subscribing to process data, along with a basic timer example.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}