[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M741XVDR0R95SJNBA1W663MA":3,"skill-same:01M741XVDR0R95SJNBA1W663MA":54},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M741XVDR0R95SJNBA1W663MA","rxjs-patterns-for-angular",null,"Implement RxJS patterns for reactive programming in Angular. Use this skill when working with Observables, operators, subscriptions, async data flows, and error handling. Covers common patterns like combineLatest, switchMap, debounceTime, catchError, retry logic, and integration with Angular Signals using toSignal() and toObservable(). Ensures proper subscription cleanup with takeUntilDestroyed().","bg-szy\u002FTOP-SKILLS","bg-szy","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F106576190?v=4","01M73A4E8KPV67SFXRY8XZGNBX","ShuZhiyong","01M73A4E96MQ294MHM74TZBVQD",6,"MIT","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frxjs-patterns-for-angular\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: rxjs-patterns-for-angular\ndescription: \"Implement RxJS patterns for reactive programming in Angular. Use this skill when working with Observables, operators, subscriptions, async data flows, and error handling. Covers common patterns like combineLatest, switchMap, debounceTime, catchError, retry logic, and integration with Angular Signals using toSignal() and toObservable(). Ensures proper subscription cleanup with takeUntilDestroyed().\"\nlicense: \"MIT\"\n---\n\n# RxJS Patterns for Angular Skill\n\nThis skill helps implement reactive patterns using RxJS in Angular applications.\n\n## Core Principles\n\n### Modern Angular + RxJS\n- **Signals First**: Use Signals for state, RxJS for async operations\n- **Auto Cleanup**: Use `takeUntilDestroyed()` for subscription management\n- **Interop**: Use `toSignal()` and `toObservable()` for Signal\u002FObservable conversion\n- **AsyncPipe**: Prefer AsyncPipe in templates when not using Signals\n\n### Key Concepts\n- Observables for async data streams\n- Operators for data transformation\n- Subscription management and cleanup\n- Error handling and retry logic\n\n## Signal + RxJS Integration\n\n### toSignal() - Observable to Signal\n\n```typescript\nimport { Component, inject } from '@angular\u002Fcore';\nimport { toSignal } from '@angular\u002Fcore\u002Frxjs-interop';\nimport { HttpClient } from '@angular\u002Fcommon\u002Fhttp';\n\n@Component({\n  selector: 'app-task-list',\n  template: `\n    @if (tasks(); as taskList) {\n      @for (task of taskList; track task.id) {\n        \u003Cdiv>{{ task.title }}\u003C\u002Fdiv>\n      }\n    }\n  `\n})\nexport class TaskListComponent {\n  private http = inject(HttpClient);\n  \n  \u002F\u002F Convert Observable to Signal\n  tasks = toSignal(\n    this.http.get\u003CTask[]>('\u002Fapi\u002Ftasks'),\n    { initialValue: [] }\n  );\n}\n```\n\n### toObservable() - Signal to Observable\n\n```typescript\nimport { Component, signal } from '@angular\u002Fcore';\nimport { toObservable } from '@angular\u002Fcore\u002Frxjs-interop';\nimport { switchMap } from 'rxjs\u002Foperators';\n\n@Component({\n  selector: 'app-search',\n  template: `\n    \u003Cinput \n      nz-input \n      [ngModel]=\"searchQuery()\" \n      (ngModelChange)=\"searchQuery.set($event)\" \n    \u002F>\n    \n    @if (results(); as resultList) {\n      @for (result of resultList; track result.id) {\n        \u003Cdiv>{{ result.name }}\u003C\u002Fdiv>\n      }\n    }\n  `\n})\nexport class SearchComponent {\n  searchQuery = signal('');\n  \n  \u002F\u002F Convert Signal to Observable and transform\n  private searchQuery$ = toObservable(this.searchQuery);\n  \n  results = toSignal(\n    this.searchQuery$.pipe(\n      debounceTime(300),\n      distinctUntilChanged(),\n      switchMap(query => this.searchService.search(query))\n    ),\n    { initialValue: [] }\n  );\n}\n```\n\n## Subscription Management\n\n### takeUntilDestroyed() - Auto Cleanup\n\n```typescript\nimport { Component, inject, signal, DestroyRef } from '@angular\u002Fcore';\nimport { takeUntilDestroyed } from '@angular\u002Fcore\u002Frxjs-interop';\nimport { interval } from 'rxjs';\n\n@Component({\n  selector: 'app-timer',\n  template: `\u003Cdiv>Time: {{ time() }}\u003C\u002Fdiv>`\n})\nexport class TimerComponent {\n  private destroyRef = inject(DestroyRef);\n  time = signal(0);\n  \n  constructor() {\n    \u002F\u002F Subscription automatically cleaned up on component destroy\n    interval(1000)\n      .pipe(takeUntilDestroyed(this.destroyRef))\n      .subscribe(value => this.time.set(value));\n  }\n}\n```\n\n### Manual Cleanup (Legacy Pattern - Avoid)\n\n```typescript\n\u002F\u002F ❌ DON'T: Manual subscription management (old pattern)\nexport class LegacyComponent implements OnDestroy {\n  private subscription = new Subscription();\n  \n  ngOnInit() {\n    this.subscription.add(\n      this.dataService.getData().subscribe(data => {\n        \u002F\u002F handle data\n      })\n    );\n  }\n  \n  ngOnDestroy() {\n    this.subscription.unsubscribe();\n  }\n}\n\n\u002F\u002F ✅ DO: Use takeUntilDestroyed()\nexport class ModernComponent {\n  private destroyRef = inject(DestroyRef);\n  data = signal\u003Cany>(null);\n  \n  constructor() {\n    this.dataService.getData()\n      .pipe(takeUntilDestroyed(this.destroyRef))\n      .subscribe(data => this.data.set(data));\n  }\n}\n```\n\n## Common Operators\n\n### switchMap - Switch to New Observable\n\n```typescript\n\u002F\u002F Switch to new search on every query change\nsearchResults$ = this.searchQuery$.pipe(\n  debounceTime(300),\n  switchMap(query => this.http.get(`\u002Fapi\u002Fsearch?q=${query}`))\n);\n```\n\n### mergeMap - Merge Multiple Observables\n\n```typescript\n\u002F\u002F Process all tasks in parallel\nprocessTasks$ = this.tasks$.pipe(\n  mergeMap(tasks => \n    from(tasks).pipe(\n      mergeMap(task => this.processTask(task))\n    )\n  )\n);\n```\n\n### concatMap - Process Sequentially\n\n```typescript\n\u002F\u002F Process tasks one by one in order\nprocessTasks$ = this.tasks$.pipe(\n  concatMap(tasks =>\n    from(tasks).pipe(\n      concatMap(task => this.processTask(task))\n    )\n  )\n);\n```\n\n### debounceTime - Debounce Input\n\n```typescript\n\u002F\u002F Wait 300ms after user stops typing\nsearch$ = this.searchInput$.pipe(\n  debounceTime(300),\n  distinctUntilChanged(),\n  switchMap(query => this.searchService.search(query))\n);\n```\n\n### distinctUntilChanged - Skip Duplicates\n\n```typescript\n\u002F\u002F Only emit when value actually changes\nstatus$ = this.statusSubject$.pipe(\n  distinctUntilChanged()\n);\n```\n\n### filter - Filter Values\n\n```typescript\n\u002F\u002F Only emit non-empty strings\nnonEmptySearch$ = this.searchQuery$.pipe(\n  filter(query => query.trim().length > 0),\n  switchMap(query => this.search(query))\n);\n```\n\n### map - Transform Values\n\n```typescript\n\u002F\u002F Transform task to display format\ntaskDisplay$ = this.task$.pipe(\n  map(task => ({\n    title: task.title,\n    status: task.status.toUpperCase(),\n    dueDate: formatDate(task.dueDate)\n  }))\n);\n```\n\n### tap - Side Effects\n\n```typescript\n\u002F\u002F Log without transforming\ntasks$ = this.http.get\u003CTask[]>('\u002Fapi\u002Ftasks').pipe(\n  tap(tasks => console.log('Loaded tasks:', tasks.length)),\n  tap(tasks => this.analyticsService.track('tasks_loaded'))\n);\n```\n\n## Combining Observables\n\n### combineLatest - Wait for All\n\n```typescript\nimport { combineLatest } from 'rxjs';\n\n\u002F\u002F Combine multiple observables\nviewModel$ = combineLatest([\n  this.tasks$,\n  this.users$,\n  this.settings$\n]).pipe(\n  map(([tasks, users, settings]) => ({\n    tasks,\n    users,\n    settings\n  }))\n);\n\n\u002F\u002F Convert to Signal\nviewModel = toSignal(this.viewModel$);\n```\n\n### forkJoin - Wait for All to Complete\n\n```typescript\nimport { forkJoin } from 'rxjs';\n\n\u002F\u002F Load multiple resources in parallel\nloadAll$ = forkJoin({\n  tasks: this.taskService.getTasks(),\n  users: this.userService.getUsers(),\n  projects: this.projectService.getProjects()\n}).pipe(\n  map(({ tasks, users, projects }) => ({\n    tasks,\n    users,\n    projects\n  }))\n);\n```\n\n### merge - Merge Multiple Streams\n\n```typescript\nimport { merge } from 'rxjs';\n\n\u002F\u002F Combine multiple event streams\nallEvents$ = merge(\n  this.createEvent$,\n  this.updateEvent$,\n  this.deleteEvent$\n).pipe(\n  tap(event => this.handleEvent(event))\n);\n```\n\n### zip - Pair Up Values\n\n```typescript\nimport { zip } from 'rxjs';\n\n\u002F\u002F Pair up matching values from two streams\npaired$ = zip(\n  this.stream1$,\n  this.stream2$\n).pipe(\n  map(([value1, value2]) => ({ value1, value2 }))\n);\n```\n\n## Error Handling\n\n### catchError - Handle Errors\n\n```typescript\ntasks$ = this.http.get\u003CTask[]>('\u002Fapi\u002Ftasks').pipe(\n  catchError(error => {\n    console.error('Failed to load tasks:', error);\n    this.notificationService.error('Failed to load tasks');\n    return of([]); \u002F\u002F Return empty array as fallback\n  })\n);\n```\n\n### retry - Retry on Failure\n\n```typescript\ntasks$ = this.http.get\u003CTask[]>('\u002Fapi\u002Ftasks').pipe(\n  retry(3), \u002F\u002F Retry up to 3 times\n  catchError(error => {\n    console.error('Failed after 3 retries:', error);\n    return of([]);\n  })\n);\n```\n\n### retryWhen - Conditional Retry with Backoff\n\n```typescript\nimport { retryWhen, delay, scan, throwError } from 'rxjs';\n\ntasks$ = this.http.get\u003CTask[]>('\u002Fapi\u002Ftasks').pipe(\n  retryWhen(errors =>\n    errors.pipe(\n      scan((retryCount, error) => {\n        if (retryCount >= 3) {\n          throw error; \u002F\u002F Max retries reached\n        }\n        console.log(`Retry ${retryCount + 1}\u002F3`);\n        return retryCount + 1;\n      }, 0),\n      delay(1000) \u002F\u002F Wait 1 second between retries\n    )\n  ),\n  catchError(error => {\n    console.error('Failed after retries:', error);\n    return of([]);\n  })\n);\n```\n\n## Real-Time Data\n\n### interval - Periodic Updates\n\n```typescript\nimport { interval, switchMap } from 'rxjs';\n\n\u002F\u002F Poll every 30 seconds\nliveData$ = interval(30000).pipe(\n  startWith(0), \u002F\u002F Emit immediately\n  switchMap(() => this.http.get('\u002Fapi\u002Flive-data')),\n  takeUntilDestroyed(this.destroyRef)\n);\n\nliveData = toSignal(this.liveData$);\n```\n\n### WebSocket Pattern\n\n```typescript\nimport { webSocket } from 'rxjs\u002FwebSocket';\n\nexport class RealtimeService {\n  private socket$ = webSocket('wss:\u002F\u002Fapi.example.com\u002Fws');\n  \n  messages$ = this.socket$.pipe(\n    catchError(error => {\n      console.error('WebSocket error:', error);\n      return EMPTY;\n    }),\n    retry({ delay: 5000 }) \u002F\u002F Reconnect after 5 seconds\n  );\n  \n  sendMessage(msg: any): void {\n    this.socket$.next(msg);\n  }\n}\n```\n\n## Loading States\n\n### Share Loading State\n\n```typescript\nimport { shareReplay } from 'rxjs';\n\n@Injectable({ providedIn: 'root' })\nexport class TaskService {\n  private http = inject(HttpClient);\n  \n  \u002F\u002F Cache and share the result\n  tasks$ = this.http.get\u003CTask[]>('\u002Fapi\u002Ftasks').pipe(\n    shareReplay({ bufferSize: 1, refCount: true })\n  );\n}\n```\n\n### Loading Indicator Pattern\n\n```typescript\n@Component({\n  selector: 'app-task-list',\n  template: `\n    @if (loading()) {\n      \u003Cnz-spin \u002F>\n    } @else if (error()) {\n      \u003Cnz-alert nzType=\"error\" [nzMessage]=\"error()!\" \u002F>\n    } @else {\n      @for (task of tasks(); track task.id) {\n        \u003Cdiv>{{ task.title }}\u003C\u002Fdiv>\n      }\n    }\n  `\n})\nexport class TaskListComponent {\n  private taskService = inject(TaskService);\n  private destroyRef = inject(DestroyRef);\n  \n  loading = signal(false);\n  error = signal\u003Cstring | null>(null);\n  tasks = signal\u003CTask[]>([]);\n  \n  constructor() {\n    this.loadTasks();\n  }\n  \n  loadTasks(): void {\n    this.loading.set(true);\n    this.error.set(null);\n    \n    this.taskService.tasks$\n      .pipe(takeUntilDestroyed(this.destroyRef))\n      .subscribe({\n        next: (tasks) => {\n          this.tasks.set(tasks);\n          this.loading.set(false);\n        },\n        error: (err) => {\n          this.error.set(err.message || 'Failed to load tasks');\n          this.loading.set(false);\n        }\n      });\n  }\n}\n```\n\n## Advanced Patterns\n\n### Throttle vs Debounce\n\n```typescript\nimport { throttleTime, debounceTime } from 'rxjs';\n\n\u002F\u002F Throttle: Emit first, then ignore for duration\nthrottled$ = this.clicks$.pipe(\n  throttleTime(1000) \u002F\u002F Max once per second\n);\n\n\u002F\u002F Debounce: Wait for quiet period\ndebounced$ = this.input$.pipe(\n  debounceTime(300) \u002F\u002F Wait 300ms after last input\n);\n```\n\n### Scan - Accumulate Values\n\n```typescript\n\u002F\u002F Running total\ntotal$ = this.amounts$.pipe(\n  scan((acc, value) => acc + value, 0)\n);\n\n\u002F\u002F History accumulation\nhistory$ = this.events$.pipe(\n  scan((history, event) => [...history, event], [] as Event[])\n);\n```\n\n### startWith - Initial Value\n\n```typescript\n\u002F\u002F Start with loading state\nstatus$ = this.dataLoad$.pipe(\n  map(() => 'loaded'),\n  startWith('loading')\n);\n```\n\n### pairwise - Previous + Current\n\n```typescript\n\u002F\u002F Compare with previous value\nchanges$ = this.value$.pipe(\n  pairwise(),\n  map(([prev, curr]) => ({\n    previous: prev,\n    current: curr,\n    diff: curr - prev\n  }))\n);\n```\n\n## Best Practices\n\n### ✅ DO\n\n```typescript\n\u002F\u002F Use toSignal() for reactive data in templates\ndata = toSignal(this.data$, { initialValue: [] });\n\n\u002F\u002F Use takeUntilDestroyed() for cleanup\nthis.data$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe();\n\n\u002F\u002F Use switchMap for user-triggered requests\nsearch$ = this.query$.pipe(switchMap(q => this.search(q)));\n\n\u002F\u002F Handle errors explicitly\ndata$ = this.http.get('\u002Fapi\u002Fdata').pipe(\n  catchError(err => of(null))\n);\n```\n\n### ❌ DON'T\n\n```typescript\n\u002F\u002F Don't forget to unsubscribe\nthis.data$.subscribe(); \u002F\u002F Memory leak!\n\n\u002F\u002F Don't use nested subscribes\nthis.data$.subscribe(data => {\n  this.process(data).subscribe(); \u002F\u002F Anti-pattern!\n});\n\n\u002F\u002F Don't use async pipe with signals\n@if (data$ | async) { } \u002F\u002F Use signals instead\n```\n\n## Checklist\n\nWhen using RxJS:\n\n- [ ] Use toSignal() to convert Observables to Signals\n- [ ] Use takeUntilDestroyed() for subscription cleanup\n- [ ] Handle errors with catchError()\n- [ ] Debounce user input (300ms)\n- [ ] Use switchMap for cancellable requests\n- [ ] Share expensive Observables with shareReplay()\n- [ ] Provide initial values with startWith()\n- [ ] Filter out empty\u002Fnull values\n- [ ] Test async operations\n- [ ] Document complex operator chains\n\n## References\n\n- [RxJS Documentation](https:\u002F\u002Frxjs.dev\u002F)\n- [Angular Signals + RxJS Interop](https:\u002F\u002Fangular.dev\u002Fguide\u002Fsignals\u002Frxjs-interop)\n- [RxJS Operators](https:\u002F\u002Frxjs.dev\u002Fguide\u002Foperators)\n- [Learn RxJS](https:\u002F\u002Fwww.learnrxjs.io\u002F)\n","# RxJS Patterns for Angular Skill\n\nThis skill helps implement reactive patterns using RxJS in Angular applications.\n\n## Core Principles\n\n### Modern Angular + RxJS\n- **Signals First**: Use Signals for state, RxJS for async operations\n- **Auto Cleanup**: Use `takeUntilDestroyed()` for subscription management\n- **Interop**: Use `toSignal()` and `toObservable()` for Signal\u002FObservable conversion\n- **AsyncPipe**: Prefer AsyncPipe in templates when not using Signals\n\n### Key Concepts\n- Observables for async data streams\n- Operators for data transformation\n- Subscription management and cleanup\n- Error handling and retry logic\n\n## Signal + RxJS Integration\n\n### toSignal() - Observable to Signal\n\n```typescript\nimport { Component, inject } from '@angular\u002Fcore';\nimport { toSignal } from '@angular\u002Fcore\u002Frxjs-interop';\nimport { HttpClient } from '@angular\u002Fcommon\u002Fhttp';\n\n@Component({\n  selector: 'app-task-list',\n  template: `\n    @if (tasks(); as taskList) {\n      @for (task of taskList; track task.id) {\n        \u003Cdiv>{{ task.title }}\u003C\u002Fdiv>\n      }\n    }\n  `\n})\nexport class TaskListComponent {\n  private http = inject(HttpClient);\n  \n  \u002F\u002F Convert Observable to Signal\n  tasks = toSignal(\n    this.http.get\u003CTask[]>('\u002Fapi\u002Ftasks'),\n    { initialValue: [] }\n  );\n}\n```\n\n### toObservable() - Signal to Observable\n\n```typescript\nimport { Component, signal } from '@angular\u002Fcore';\nimport { toObservable } from '@angular\u002Fcore\u002Frxjs-interop';\nimport { switchMap } from 'rxjs\u002Foperators';\n\n@Component({\n  selector: 'app-search',\n  template: `\n    \u003Cinput \n      nz-input \n      [ngModel]=\"searchQuery()\" \n      (ngModelChange)=\"searchQuery.set($event)\" \n    \u002F>\n    \n    @if (results(); as resultList) {\n      @for (result of resultList; track result.id) {\n        \u003Cdiv>{{ result.name }}\u003C\u002Fdiv>\n      }\n    }\n  `\n})\nexport class SearchComponent {\n  searchQuery = signal('');\n  \n  \u002F\u002F Convert Signal to Observable and transform\n  private searchQuery$ = toObservable(this.searchQuery);\n  \n  results = toSignal(\n    this.searchQuery$.pipe(\n      debounceTime(300),\n      distinctUntilChanged(),\n      switchMap(query => this.searchService.search(query))\n    ),\n    { initialValue: [] }\n  );\n}\n```\n\n## Subscription Management\n\n### takeUntilDestroyed() - Auto Cleanup\n\n```typescript\nimport { Component, inject, signal, DestroyRef } from '@angular\u002Fcore';\nimport { takeUntilDestroyed } from '@angular\u002Fcore\u002Frxjs-interop';\nimport { interval } from 'rxjs';\n\n@Component({\n  selector: 'app-timer',\n  template: `\u003Cdiv>Time: {{ time() }}\u003C\u002Fdiv>`\n})\nexport class TimerComponent {\n  private destroyRef = inject(DestroyRef);\n  time = signal(0);\n  \n  constructor() {\n    \u002F\u002F Subscription automatically cleaned up on component destroy\n    interval(1000)\n      .pipe(takeUntilDestroyed(this.destroyRef))\n      .subscribe(value => this.time.set(value));\n  }\n}\n```\n\n### Manual Cleanup (Legacy Pattern - Avoid)\n\n```typescript\n\u002F\u002F ❌ DON'T: Manual subscription management (old pattern)\nexport class LegacyComponent implements OnDestroy {\n  private subscription = new Subscription();\n  \n  ngOnInit() {\n    this.subscription.add(\n      this.dataService.getData().subscribe(data => {\n        \u002F\u002F handle data\n      })\n    );\n  }\n  \n  ngOnDestroy() {\n    this.subscription.unsubscribe();\n  }\n}\n\n\u002F\u002F ✅ DO: Use takeUntilDestroyed()\nexport class ModernComponent {\n  private destroyRef = inject(DestroyRef);\n  data = signal\u003Cany>(null);\n  \n  constructor() {\n    this.dataService.getData()\n      .pipe(takeUntilDestroyed(this.destroyRef))\n      .subscribe(data => this.data.set(data));\n  }\n}\n```\n\n## Common Operators\n\n### switchMap - Switch to New Observable\n\n```typescript\n\u002F\u002F Switch to new search on every query change\nsearchResults$ = this.searchQuery$.pipe(\n  debounceTime(300),\n  switchMap(query => this.http.get(`\u002Fapi\u002Fsearch?q=${query}`))\n);\n```\n\n### mergeMap - Merge Multiple Observables\n\n```typescript\n\u002F\u002F Process all tasks in parallel\nprocessTasks$ = this.tasks$.pipe(\n  mergeMap(tasks => \n    from(tasks).pipe(\n      mergeMap(task => this.processTask(task))\n    )\n  )\n);\n```\n\n### concatMap - Process Sequentially\n\n```typescript\n\u002F\u002F Process tasks one by one in order\nprocessTasks$ = this.tasks$.pipe(\n  concatMap(tasks =>\n    from(tasks).pipe(\n      concatMap(task => this.processTask(task))\n    )\n  )\n);\n```\n\n### debounceTime - Debounce Input\n\n```typescript\n\u002F\u002F Wait 300ms after user stops typing\nsearch$ = this.searchInput$.pipe(\n  debounceTime(300),\n  distinctUntilChanged(),\n  switchMap(query => this.searchService.search(query))\n);\n```\n\n### distinctUntilChanged - Skip Duplicates\n\n```typescript\n\u002F\u002F Only emit when value actually changes\nstatus$ = this.statusSubject$.pipe(\n  distinctUntilChanged()\n);\n```\n\n### filter - Filter Values\n\n```typescript\n\u002F\u002F Only emit non-empty strings\nnonEmptySearch$ = this.searchQuery$.pipe(\n  filter(query => query.trim().length > 0),\n  switchMap(query => this.search(query))\n);\n```\n\n### map - Transform Values\n\n```typescript\n\u002F\u002F Transform task to display format\ntaskDisplay$ = this.task$.pipe(\n  map(task => ({\n    title: task.title,\n    status: task.status.toUpperCase(),\n    dueDate: formatDate(task.dueDate)\n  }))\n);\n```\n\n### tap - Side Effects\n\n```typescript\n\u002F\u002F Log without transforming\ntasks$ = this.http.get\u003CTask[]>('\u002Fapi\u002Ftasks').pipe(\n  tap(tasks => console.log('Loaded tasks:', tasks.length)),\n  tap(tasks => this.analyticsService.track('tasks_loaded'))\n);\n```\n\n## Combining Observables\n\n### combineLatest - Wait for All\n\n```typescript\nimport { combineLatest } from 'rxjs';\n\n\u002F\u002F Combine multiple observables\nviewModel$ = combineLatest([\n  this.tasks$,\n  this.users$,\n  this.settings$\n]).pipe(\n  map(([tasks, users, settings]) => ({\n    tasks,\n    users,\n    settings\n  }))\n);\n\n\u002F\u002F Convert to Signal\nviewModel = toSignal(this.viewModel$);\n```\n\n### forkJoin - Wait for All to Complete\n\n```typescript\nimport { forkJoin } from 'rxjs';\n\n\u002F\u002F Load multiple resources in parallel\nloadAll$ = forkJoin({\n  tasks: this.taskService.getTasks(),\n  users: this.userService.getUsers(),\n  projects: this.projectService.getProjects()\n}).pipe(\n  map(({ tasks, users, projects }) => ({\n    tasks,\n    users,\n    projects\n  }))\n);\n```\n\n### merge - Merge Multiple Streams\n\n```typescript\nimport { merge } from 'rxjs';\n\n\u002F\u002F Combine multiple event streams\nallEvents$ = merge(\n  this.createEvent$,\n  this.updateEvent$,\n  this.deleteEvent$\n).pipe(\n  tap(event => this.handleEvent(event))\n);\n```\n\n### zip - Pair Up Values\n\n```typescript\nimport { zip } from 'rxjs';\n\n\u002F\u002F Pair up matching values from two streams\npaired$ = zip(\n  this.stream1$,\n  this.stream2$\n).pipe(\n  map(([value1, value2]) => ({ value1, value2 }))\n);\n```\n\n## Error Handling\n\n### catchError - Handle Errors\n\n```typescript\ntasks$ = this.http.get\u003CTask[]>('\u002Fapi\u002Ftasks').pipe(\n  catchError(error => {\n    console.error('Failed to load tasks:', error);\n    this.notificationService.error('Failed to load tasks');\n    return of([]); \u002F\u002F Return empty array as fallback\n  })\n);\n```\n\n### retry - Retry on Failure\n\n```typescript\ntasks$ = this.http.get\u003CTask[]>('\u002Fapi\u002Ftasks').pipe(\n  retry(3), \u002F\u002F Retry up to 3 times\n  catchError(error => {\n    console.error('Failed after 3 retries:', error);\n    return of([]);\n  })\n);\n```\n\n### retryWhen - Conditional Retry with Backoff\n\n```typescript\nimport { retryWhen, delay, scan, throwError } from 'rxjs';\n\ntasks$ = this.http.get\u003CTask[]>('\u002Fapi\u002Ftasks').pipe(\n  retryWhen(errors =>\n    errors.pipe(\n      scan((retryCount, error) => {\n        if (retryCount >= 3) {\n          throw error; \u002F\u002F Max retries reached\n        }\n        console.log(`Retry ${retryCount + 1}\u002F3`);\n        return retryCount + 1;\n      }, 0),\n      delay(1000) \u002F\u002F Wait 1 second between retries\n    )\n  ),\n  catchError(error => {\n    console.error('Failed after retries:', error);\n    return of([]);\n  })\n);\n```\n\n## Real-Time Data\n\n### interval - Periodic Updates\n\n```typescript\nimport { interval, switchMap } from 'rxjs';\n\n\u002F\u002F Poll every 30 seconds\nliveData$ = interval(30000).pipe(\n  startWith(0), \u002F\u002F Emit immediately\n  switchMap(() => this.http.get('\u002Fapi\u002Flive-data')),\n  takeUntilDestroyed(this.destroyRef)\n);\n\nliveData = toSignal(this.liveData$);\n```\n\n### WebSocket Pattern\n\n```typescript\nimport { webSocket } from 'rxjs\u002FwebSocket';\n\nexport class RealtimeService {\n  private socket$ = webSocket('wss:\u002F\u002Fapi.example.com\u002Fws');\n  \n  messages$ = this.socket$.pipe(\n    catchError(error => {\n      console.error('WebSocket error:', error);\n      return EMPTY;\n    }),\n    retry({ delay: 5000 }) \u002F\u002F Reconnect after 5 seconds\n  );\n  \n  sendMessage(msg: any): void {\n    this.socket$.next(msg);\n  }\n}\n```\n\n## Loading States\n\n### Share Loading State\n\n```typescript\nimport { shareReplay } from 'rxjs';\n\n@Injectable({ providedIn: 'root' })\nexport class TaskService {\n  private http = inject(HttpClient);\n  \n  \u002F\u002F Cache and share the result\n  tasks$ = this.http.get\u003CTask[]>('\u002Fapi\u002Ftasks').pipe(\n    shareReplay({ bufferSize: 1, refCount: true })\n  );\n}\n```\n\n### Loading Indicator Pattern\n\n```typescript\n@Component({\n  selector: 'app-task-list',\n  template: `\n    @if (loading()) {\n      \u003Cnz-spin \u002F>\n    } @else if (error()) {\n      \u003Cnz-alert nzType=\"error\" [nzMessage]=\"error()!\" \u002F>\n    } @else {\n      @for (task of tasks(); track task.id) {\n        \u003Cdiv>{{ task.title }}\u003C\u002Fdiv>\n      }\n    }\n  `\n})\nexport class TaskListComponent {\n  private taskService = inject(TaskService);\n  private destroyRef = inject(DestroyRef);\n  \n  loading = signal(false);\n  error = signal\u003Cstring | null>(null);\n  tasks = signal\u003CTask[]>([]);\n  \n  constructor() {\n    this.loadTasks();\n  }\n  \n  loadTasks(): void {\n    this.loading.set(true);\n    this.error.set(null);\n    \n    this.taskService.tasks$\n      .pipe(takeUntilDestroyed(this.destroyRef))\n      .subscribe({\n        next: (tasks) => {\n          this.tasks.set(tasks);\n          this.loading.set(false);\n        },\n        error: (err) => {\n          this.error.set(err.message || 'Failed to load tasks');\n          this.loading.set(false);\n        }\n      });\n  }\n}\n```\n\n## Advanced Patterns\n\n### Throttle vs Debounce\n\n```typescript\nimport { throttleTime, debounceTime } from 'rxjs';\n\n\u002F\u002F Throttle: Emit first, then ignore for duration\nthrottled$ = this.clicks$.pipe(\n  throttleTime(1000) \u002F\u002F Max once per second\n);\n\n\u002F\u002F Debounce: Wait for quiet period\ndebounced$ = this.input$.pipe(\n  debounceTime(300) \u002F\u002F Wait 300ms after last input\n);\n```\n\n### Scan - Accumulate Values\n\n```typescript\n\u002F\u002F Running total\ntotal$ = this.amounts$.pipe(\n  scan((acc, value) => acc + value, 0)\n);\n\n\u002F\u002F History accumulation\nhistory$ = this.events$.pipe(\n  scan((history, event) => [...history, event], [] as Event[])\n);\n```\n\n### startWith - Initial Value\n\n```typescript\n\u002F\u002F Start with loading state\nstatus$ = this.dataLoad$.pipe(\n  map(() => 'loaded'),\n  startWith('loading')\n);\n```\n\n### pairwise - Previous + Current\n\n```typescript\n\u002F\u002F Compare with previous value\nchanges$ = this.value$.pipe(\n  pairwise(),\n  map(([prev, curr]) => ({\n    previous: prev,\n    current: curr,\n    diff: curr - prev\n  }))\n);\n```\n\n## Best Practices\n\n### ✅ DO\n\n```typescript\n\u002F\u002F Use toSignal() for reactive data in templates\ndata = toSignal(this.data$, { initialValue: [] });\n\n\u002F\u002F Use takeUntilDestroyed() for cleanup\nthis.data$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe();\n\n\u002F\u002F Use switchMap for user-triggered requests\nsearch$ = this.query$.pipe(switchMap(q => this.search(q)));\n\n\u002F\u002F Handle errors explicitly\ndata$ = this.http.get('\u002Fapi\u002Fdata').pipe(\n  catchError(err => of(null))\n);\n```\n\n### ❌ DON'T\n\n```typescript\n\u002F\u002F Don't forget to unsubscribe\nthis.data$.subscribe(); \u002F\u002F Memory leak!\n\n\u002F\u002F Don't use nested subscribes\nthis.data$.subscribe(data => {\n  this.process(data).subscribe(); \u002F\u002F Anti-pattern!\n});\n\n\u002F\u002F Don't use async pipe with signals\n@if (data$ | async) { } \u002F\u002F Use signals instead\n```\n\n## Checklist\n\nWhen using RxJS:\n\n- [ ] Use toSignal() to convert Observables to Signals\n- [ ] Use takeUntilDestroyed() for subscription cleanup\n- [ ] Handle errors with catchError()\n- [ ] Debounce user input (300ms)\n- [ ] Use switchMap for cancellable requests\n- [ ] Share expensive Observables with shareReplay()\n- [ ] Provide initial values with startWith()\n- [ ] Filter out empty\u002Fnull values\n- [ ] Test async operations\n- [ ] Document complex operator chains\n\n## References\n\n- [RxJS Documentation](https:\u002F\u002Frxjs.dev\u002F)\n- [Angular Signals + RxJS Interop](https:\u002F\u002Fangular.dev\u002Fguide\u002Fsignals\u002Frxjs-interop)\n- [RxJS Operators](https:\u002F\u002Frxjs.dev\u002Fguide\u002Foperators)\n- [Learn RxJS](https:\u002F\u002Fwww.learnrxjs.io\u002F)\n",{"name":5,"license":15,"description":7},"master","63f17866001c5ca854bf2fa0b678ce277133de5b","skills\u002Fmarketplace\u002Frxjs-patterns-for-angular",0,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS","https:\u002F\u002Fbg-szy.github.io\u002FTOP-SKILLS\u002F","https:\u002F\u002Fgithub.com\u002Fbg-szy","https:\u002F\u002Fwww.ecust.edu.cn\u002F","a student of East China University of Science and Technology","2026-11-15 03:38:02",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add bg-szy\u002FTOP-SKILLS --skill rxjs-patterns-for-angular",{"tool":40,"command":41},"bunx","bunx skills add bg-szy\u002FTOP-SKILLS --skill rxjs-patterns-for-angular",{"tool":43,"command":44},"pnpm","pnpm dlx skills add bg-szy\u002FTOP-SKILLS --skill rxjs-patterns-for-angular","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frxjs-patterns-for-angular\u002FSKILL.md",true,[48],{"path":49,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":52,"sourceHtmlUrl":53},"skill-report.json","REFERENCE","参考文档",71143,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frxjs-patterns-for-angular\u002Fskill-report.json",[55,63,70,77,84,91],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":62},"01M7DXW9N826PKXK174PVW3038","serpmaven","Scrape Google search results (SERP) to JSON with SERP Maven (serpmaven) - a real Chrome browser on a residential proxy with sticky sessions. Run it as a CLI, a Python library, a local HTTP search API (`serve`), an MCP server or a Docker image; set the proxy login, workers, pages and cost tracking. Use when the user wants Google results, rank tracking, a self-hosted SERP API, or live Google search for an AI agent.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fserpmaven\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":62},"01M7DXVHSTWDV65475QEQ915M7","revnu-landing-page-audit","Find out why a landing page isn't turning visitors into signups, demos or sales. Audits one page against what the ad, post or search that sends people there promised, then checks the first screen, proof, call to action, friction and mobile. Returns at most 7 prioritized fixes, plus what is fine and what could not be checked; rewrites specific lines and fixes the page in the repo when asked. Never promises a conversion lift. Works without a Revnu account. Use when the user says or asks: \"audit my landing page\", \"why isn't this page converting\", \"review my homepage\", \"my ads get clicks but no signups\", \"people bounce from the pricing page\", \"CRO review\", \"improve conversion rate\", \"is my hero section clear\", \"roast my landing page\", \"rewrite my headline\", \"what's wrong with this page\", \"landing page feedback\", \"make the signup page convert better\". Not for SEO or AI-search audits, page speed engineering on its own, or building a new page from scratch.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-landing-page-audit\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":62},"01M7DXV8X2D7B3VTD4HHYYHTGR","revnu-growth-context","Write down once who buys, what they're stuck on, what it costs, what proof you have and what you've already tried, so every growth task starts from facts instead of a questionnaire. Creates or updates .agents\u002Frevnu-growth.md from the repo, the live site and the user, and imports an existing product-marketing.md. Use when the user says \"set up our marketing context\", \"who is our ideal customer\", \"write our ICP\", \"describe the product for marketing\", \"positioning doc\", \"what's our brand voice\", \"remember this about our customers\", \"log what we tried\", \"what have we learned from marketing\", \"we changed pricing, update the context\", \"update our growth notes\", \"summarize the business for the agent\", \"import my product-marketing.md\", \"start a growth doc\", or before a first marketing, SEO, outreach or launch task when no context file exists. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-growth-context\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":62},"01M7DXV0DGJ1G0A60PAHC6J3C5","revnu-get-listed","Get onto the third-party pages AI answers and search cite when buyers ask for the best tool in your category: \"best X\" roundups, directories, review sites, GitHub awesome lists, community threads and comparison pages. Finds which ones are cited, ranks them by fit and effort, and drafts each submission, PR or pitch by the target's own rules. Use when the user says \"get us listed\", \"which directories should we submit to\", \"how do we get into best-of lists\", \"why does ChatGPT recommend competitors and not us\", \"get mentioned in AI answers\", \"submit to awesome lists\", \"get on G2\", \"where are our competitors listed\", \"pitch listicle authors\", \"find backlink opportunities\", \"launch directories\", \"get into roundups\", \"Product Hunt alternatives\", \"where should we be listed\", \"get cited by Perplexity\". Never submits, pays or posts without a yes. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-get-listed\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":62},"01M7DXTSPMGT9D6DSS0HP9BSTA","revnu-ai-readiness-audit","Audit whether your website gives ChatGPT, Perplexity, Claude, Gemini and Google's AI Overviews something worth quoting, and fix the pages that don't. Use when the user says or asks \"is my site ready for AI search\", \"audit my site for AI answers\", \"AEO audit\", \"GEO audit\", \"why doesn't ChatGPT quote our pricing\", \"make our pages citable by AI\", \"do I need llms.txt\", \"does schema help with ChatGPT\", \"check our structured data\", \"is our content visible without JavaScript\", \"AI SEO audit\", \"optimize our homepage for AI answers\", \"LLM SEO check\", \"why does AI get our product wrong\", \"fix our site for AI Overviews\". Checks fetchability and indexability, answers in the raw HTML, entity facts, schema (including JS-injected markup), headings, dates and llms.txt, then gives at most 10 prioritised fixes and edits the repo when asked. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-ai-readiness-audit\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":62},"01M7DXSZHCVTRS620GC3S97JZV","proxy-troubleshooting","Diagnose residential proxy failures, with NodeMaven's gateway as the reference - 407 with correct credentials, 406, 410, 500, a connection that hangs, ERR_TUNNEL_CONNECTION_FAILED in a browser, Playwright or Puppeteer ignoring proxy credentials, a sticky session that changes IP, geo-targeting that is silently ignored, passwords with special characters, and unexpected traffic from headless Chrome. Use when a proxy connection fails, returns the wrong location, or costs more traffic than expected.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fproxy-troubleshooting\u002FSKILL.md",[],[]]