angular-rxjs-patterns

Implements reactive async data flows in Angular using RxJS observables, operators, and subjects.

Updated Jun 28, 2026
One-click install
npx skills add https://github.com/412181-HerediaLara/ScaffoldingBE-FE --skill angular-rxjs-patterns-412181-heredialara
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: angular-rxjs-patterns
Source: https://github.com/412181-HerediaLara/ScaffoldingBE-FE/tree/main/FE/.agents/skills/angular-rxjs-patterns
Command: npx skills add https://github.com/412181-HerediaLara/ScaffoldingBE-FE --skill angular-rxjs-patterns-412181-heredialara

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires rxjs, @angular/core, @angular/common.

What problem does it solve? Managing asynchronous operations in Angular—HTTP requests, user input streams, real-time updates—often leads to memory leaks, callback hell, duplicate requests, and unhandled errors when done imperatively. This Skill provides proven RxJS patterns for handling these challenges declaratively. ## Core Features & Use Cases - Observable & Operator Patterns: Covers creation, transformation (map, switchMap, mergeMap), filtering (debounceTime, distinctUntilChanged), and combination (combineLatest, forkJoin) operators with Angular HttpClient. - Subscription & Memory Management: Uses takeUntilDestroyed, DestroyRef, and the async pipe to prevent memory leaks without manual ngOnDestroy logic. - State & Error Handling: Demonstrates BehaviorSubject-based state services, signal integration, catchError strategies, and retry with exponential backoff. - Use Case: Build a search feature where user keystrokes are debounced by 300ms, duplicate terms are skipped, in-flight requests are cancelled via switchMap, and errors fall back gracefully. ## Quick Start Ask the AI to implement a debounced search service in Angular using RxJS switchMap with proper error handling and automatic subscription cleanup.

Frequently Asked Questions about angular-rxjs-patterns

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

FAQPage Schema
How do I handle HTTP requests with RxJS in Angular?

Use Angular's HttpClient, which returns observables for get, post, put, and delete operations. Pipe the results through operators like map, catchError, and retry, then subscribe in components or expose them to templates with the async pipe.

How to prevent memory leaks from RxJS subscriptions in Angular?

Use takeUntilDestroyed from @angular/core/rxjs-interop, which automatically unsubscribes when the component is destroyed without needing ngOnDestroy. Alternatively, use the async pipe in templates or DestroyRef for imperative subscriptions.

What is the difference between switchMap, mergeMap, and concatMap?

switchMap cancels the previous inner observable when a new value arrives, ideal for search inputs. mergeMap runs all inner observables in parallel, while concatMap queues them and executes sequentially, preserving order.

Should I use BehaviorSubject or signals for Angular state management?

Prefer signals for synchronous state in modern Angular, using computed for derived values. Use BehaviorSubject when you need observable streams, and convert observables to signals with toSignal when rendering async data in templates.

How do I retry failed HTTP requests with RxJS?

Use the retry operator for a fixed number of attempts, or retryWhen combined with delay and take for delayed retries. For exponential backoff, use retryWhen with mergeMap to compute increasing delays based on the attempt index.

Why does my Angular HTTP request fire multiple times?

Cold observables like HttpClient requests execute once per subscription, so multiple subscribers trigger duplicate requests. Apply shareReplay(1) to cache the last emitted value and share a single execution across all subscribers.