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)