ANGULAR 🔺: Signals
ANGULAR 🔺: Signals
🌶️ Signals are to #Angular what Hooks were to #React in 2019.
It will have a major impact on the programming model, best practices, libraries & ecosystem.
Projects who don't want to become "legacy" are in for a big rewrite ...
So what are signals?
A good starting point is to look at how Solid, a relatively new and increasingly popular framework that is built around signals describes them.
Especially, the Angular team worked closely with its creator and CEO of Signals Ryan Carniato to develop Angular's version of them:
Signals are the cornerstone of reactivity in Solid.
They contain values that change over time; when you change a signal's value, it automatically updates anything that uses it.
That seems pretty straightforward.
A signal is a wrapper around a simple value that registers what depends on that value and notifies those dependents whenever its value changes.
A comparison often used to describe them to people familiar with RxJs is BehaviorSubjects, except for the need to manually subscribe/unsubscribe.
Signals always have a value, signals are side-effect-free, and signals are reactive, keeping their dependents in sync.
Together they deliver one simple model of how things change in Angular applications.
Something that does not quite exist today.
Angular Signals are zero-argument functions (() => T).
When executed, they return the current value of the signal.
Executing signals does not trigger side effects, though it may lazily recompute intermediate values (lazy memoization).
Particular contexts (such as template expressions) can be reactive.
It truly is an exciting time in the Angular community.
I am 1000% convinced that signals will significantly improve the developer and user experience of Angular applications.
They provide one simple model to update Angular's views.
They are performant, and reactive, and will soon be an indispensable part of Angular.
I hope you are now equipped with the knowledge to take full advantage of signals when they land later this year.