AgentStack
SKILL verified MIT Self-run

Angular Reactivity

skill-cuongtl1992-vibe-skills-angular-reactivity · by cuongtl1992

Angular reactive patterns combining signals (signal(), computed(), effect(), linkedSignal()) for UI state with RxJS (Subject, switchMap, exhaustMap, race, combineLatest) for async event streams, plus interop (toSignal(), toObservable()). Use when working with reactive state, derived values, async event handling, or state management. ALWAYS use when creating state services or wiring Subject stream…

No reviews yet
0 installs
12 views
0.0% view→install

Install

$ agentstack add skill-cuongtl1992-vibe-skills-angular-reactivity

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of Angular Reactivity? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Angular Reactivity — Signals + RxJS

Signals handle state; RxJS handles streams. They interop via toSignal() and toObservable().

When to Use What

| Use Signals | Use RxJS | | ---------------------------------- | -------------------------------------------- | | UI state (loading, error, filters) | Async event streams (click, submit) | | Derived/computed values | debounceTime, distinctUntilChanged | | Simple read/write state | switchMap, exhaustMap, combineLatest | | Template bindings | Dialog handling (race, firstValueFrom) | | Component inputs/outputs | Complex async orchestration |

Signal Essentials

// Writable
private readonly _items = signal([]);
readonly items = this._items.asReadonly();

// Modify
this._items.set(newItems);
this._items.update(items => items.filter(i => i.id !== id));

// Computed (auto-updates)
readonly hasItems = computed(() => this._items().length > 0);

// linkedSignal (resets when source changes)
readonly selectedId = linkedSignal({
  source: this.items,
  computation: (items, prev) =>
    prev && items.some(i => i.id === prev.value) ? prev.value : items[0]?.id ?? null,
});

Interop (Critical Patterns)

toSignal() — Observable to Signal

import { toSignal } from '@angular/core/rxjs-interop';
import { startWith } from 'rxjs';

// ALWAYS use startWith() to emit initial value
private readonly formStatus = toSignal(
  this.form.statusChanges.pipe(startWith(this.form.status)),
  { initialValue: this.form.status }
);

toObservable() — Signal to Observable

import { toObservable } from '@angular/core/rxjs-interop';

combineLatest([toObservable(this._keyword), toObservable(this._page)])
  .pipe(
    debounceTime(100),
    switchMap(() => this.fetchData()),
    takeUntilDestroyed(this.destroyRef)
  )
  .subscribe();

RxJS Core Pattern: Subject + Operator + takeUntilDestroyed

private readonly destroyRef = inject(DestroyRef);
private readonly deleteClick$ = new Subject();

ngOnInit(): void {
  this.deleteClick$.pipe(
    switchMap(entity => from(this.handleDelete(entity))),
    takeUntilDestroyed(this.destroyRef)  // MUST pass destroyRef in ngOnInit
  ).subscribe();
}

onDelete(entity: Entity): void { this.deleteClick$.next(entity); }

Never use takeUntilDestroyed() without args in ngOnInit() — it will throw.

Operator Selection

| Operator | When | Example | | --------------- | -------------------------- | --------------------------------- | | exhaustMap | Prevent concurrent ops | Form submit, create, delete | | switchMap | Cancel-and-restart | Search, navigation, dialog open | | debounceTime | Batch rapid changes | Filter/search auto-reload | | combineLatest | Multiple signal sources | State service reactive stream | | race | First of competing streams | Dialog submit vs close | | from() | Promise → Observable | Wrap async handler for RxJS chain |

Detailed Patterns

  • Signal state service pattern: [references/signal-patterns.md](references/signal-patterns.md)
  • RxJS event patterns (dialog, CRUD, deactivation): [references/rxjs-patterns.md](references/rxjs-patterns.md)

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.