HoangNguyen0403

RxJS Interop

Bridging Observables and Signals using toSignal and toObservable.

HoangNguyen0403 501 148 Updated 4mo ago

Resources

1
GitHub

Install

npx skillscat add hoangnguyen0403/agent-skills-standard/rxjs-interop

Install via the SkillsCat registry.

SKILL.md

RxJS Interop

Priority: P1 (HIGH)

Principles

  • Async to Sync: Use toSignal to convert Observables (HTTP, Events) to Signals for template rendering.
  • Sync to Async: Use toObservable when you need RxJS operators (debounce, switchMap) on a Signal.
  • Auto-Unsubscribe: toSignal automatically unsubscribes.
  • Cleanup: Use takeUntilDestroyed for manual subscriptions in injection contexts.

Guidelines

  • HTTP Requests:
    • GET: http.get().pipe(...) -> toSignal()
    • POST/PUT: Trigger explicit subscribe() or lastValueFrom().
  • Race Conditions: Handle async loading states. toSignal requires an initialValue or handles undefined.

References