rxjs

Guide RxJS usage in Angular with reactive patterns and declarative operators.

Updated Feb 17, 2026
One-click install
npx skills add https://github.com/Objective-Arts/lens-dist --skill rxjs-objective-arts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rxjs
Source: https://github.com/Objective-Arts/lens-dist/tree/main/canon/rxjs
Command: npx skills add https://github.com/Objective-Arts/lens-dist --skill rxjs-objective-arts

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers understand and apply the core principles of RxJS effectively within Angular applications, preventing common pitfalls and promoting robust asynchronous programming.

Core Features & Use Cases

  • RxJS Best Practices: Learn when to use RxJS, how to avoid nested subscribes, and the proper use of higher-order mapping operators.
  • Error Handling & Unsubscription: Implement strategies for reliable error management and prevent memory leaks through proper unsubscription.
  • Use Case: Refactor a complex Angular component that is experiencing performance issues due to multiple, unmanaged HTTP requests triggered by nested subscriptions, ensuring each request is handled efficiently and only executed once.

Quick Start

Review the RxJS best practices for handling asynchronous operations in Angular.

Frequently Asked Questions about rxjs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I avoid nested subscriptions in Angular RxJS?

Avoid nested subscriptions in Angular RxJS by using declarative higher-order mapping operators like switchMap and mergeMap to compose asynchronous streams. This prevents unmanaged HTTP requests and performance issues by flattening nested observables into a single continuous stream.

What is the difference between Angular Signals and RxJS Observables?

Angular Signals manage synchronous state, whereas RxJS Observables handle asynchronous streams over time. Distinguishing them ensures you apply reactive programming correctly, using Signals for immediate state mutations and Observables for managing continuous asynchronous data flows.

How do I handle unsubscription to prevent memory leaks in reactive Angular apps?

Handle unsubscription in reactive Angular apps to prevent memory leaks by applying proper unsubscription strategies. Using declarative RxJS operators and the async pipe automatically manages subscriptions, ensuring streams are cleaned up when components are destroyed.

When should I use switchMap vs mergeMap in RxJS?

Use switchMap vs mergeMap in RxJS based on your stream requirements: switchMap cancels previous in-flight requests when a new value arrives, ideal for search inputs, while mergeMap runs requests concurrently to handle multiple asynchronous events simultaneously.

What is the best way to handle errors in RxJS streams for Angular?

The best way to handle errors in RxJS streams for Angular is implementing reliable error management strategies within your asynchronous stream composition. Using declarative operators ensures stream continuity and handles failures gracefully without breaking the application flow.

Why does my Angular component trigger duplicate HTTP requests with RxJS?

Your Angular component triggers duplicate HTTP requests with RxJS due to improper stream composition. Refactor nested subscriptions using declarative operators like shareReplay to cache and efficiently execute each HTTP request only once.