Skip to the page

Signals · mid

httpResource, and signals or RxJS

httpResource loads data from a signal-based URL and gives signals for loading, error and value. Choose signals for UI state and RxJS for streams over time.

The notes

What you must know

  • httpResource and resource are stable in v22 (facts.md).
  • Example: orders = httpResource<Order[]>(() => "/api/customers/" + this.customerId() + "/orders"). When the input signal changes, it loads again.
  • The resource gives isLoading(), error(), hasValue(), value() and reload(). Use them in @if blocks.
  • Signals are synchronous, always have a value, update templates precisely, need no subscribe and drive zoneless change detection.
  • RxJS is best for streams of events over time with cancellation and time operators: debounce, throttle, retry, combining sources.
  • They work together: toSignal and toObservable convert between them.
  • Migrating an old component: write tests first, take a profiler baseline, run the signal schematics (inputs, outputs, queries), then review by hand.
  • Inputs the component writes to are skipped by the schematic: they need model() or a redesign.

The red pen

Common traps: mistake → fix

  • Mistake: Signals replace RxJS

    Fix: they cover state; RxJS stays for streams and events (facts.md).

  • Mistake: A migration schematic finishes the job

    Fix: it skips some cases and you must review by hand.

Easy to hard

Questions interviewers ask, easy to hard

  1. What does httpResource give you compared with HttpClient and a subscription?
  2. When would you choose RxJS over a signal?
  3. How do you move a big old component to signals safely?
  4. How do you turn an Observable into a signal?

Practise

Practise with these questions

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview