DEV Community

Ahmad Alhafi
Ahmad Alhafi

Posted on

Angular 19 โ€” Whatโ€™s up with Signals?

The Signals that were Developer Preview in Angular v17 are now stable ๐Ÿ™‚โ€โ†•๏ธ

These include the view/content queries (viewChild, viewChildren, contentChild, contentChildren) and also output.
If you want a refresher on them, check out this post:
https://lnkd.in/dN_kPEhu


Whatโ€™s new in Angular 19?

๐ŸŽ— linkedSignal()

Remember computed() signals? linkedSignal() works similarly, but itโ€™s writable.

It derives its value from another signal

You can also manually update it anytime you want

Example:

const count = linkedSignal(() => list().length);
count.set(0); // You can manually set it now, even though itโ€™s derived


The next three signals are designed for reactive handling of async data, providing signals for loading, error, and value states.

๐ŸŽ— resource()

A reactive API for managing async data (HTTP calls, loading, etc).

Provides loading, error, and value states as Signals

Supports reload and abort unnecessary operations (abortSignal)

Usage:

things.value();
things.error();
things.loading();

๐ŸŽ— httpResource()

A specialized version of resource() for HTTP requests using Angular HttpClient.
Instead of building a resource from scratch:

const things = httpResource({
request: () => this.http.get('/api/things'),
});

Access states the same way:

things.value();
things.error();
things.loading();

๐ŸŽ— rxResource()

For when you want to keep using RxJS Observables within Signals.
Instead of manually converting an Observable to a Signal (toSignal()), it wraps it automatically.

things.value();
things.error();
things.loading();


๐Ÿง Quick comparison

resource() โ†’ base API, you can build any resource (not just HTTP)

httpResource() โ†’ ready-to-use specialization for HTTP requests using Angular HttpClient

rxResource() โ†’ specialization for RxJS Observables to work seamlessly in the Signals ecosystem

โš ๏ธ All these new Signals in Angular 19 are Developer Preview.


And thatโ€™s it!
If youโ€™re still unsure how it works, check out this post:
https://lnkd.in/dvFG2P3d

Top comments (0)