Angular Signals: The Lost Guide
Welcome to my new article, Angular Signals: The Lost Guide, where I'll introduce the new native way to handle reactivity in modern Angular! To get familiar with it, think of a Signal as a box that stores a value and automatically notifies everything that is "listening" whenever the value changes. It's similar to an RxJS BehaviorSubject, but without having to instantiate classes, call next() or manage subscribe().

Creating Writable Signals
Writable Signals are the foundation of the new reactive state management model. They represent values that can be read and also updated, safely and efficiently.
To create a writable signal, the API is extremely simple and straightforward:

The function signal<T>(initialValue) takes an initial value and returns a signal that stores that value. This signal can be read directly as a function, for example counter() returns the current value, and it can also be modified using the set() or update() methods (which we'll see later).

What happens under the hood?
Although using it looks simple, Angular implements a sophisticated structure behind this API. Signals use closures to encapsulate the stored value. This means the function created when you call signal() keeps a safe, isolated reference to the internal value, protecting it from improper access and letting the framework track every read or write of that value.
This closure-based approach ensures that state changes are tracked efficiently, which is essential for Angular's reactivity to work correctly.
The small snippet above already shows the power and simplicity of writable signals. It encapsulates state, allows controlled changes and serves as the foundation for more advanced structures such as computed and effect, which we'll see next.
Modifying a Writable Signal
Once a Writable Signal is created, you can change its value in a controlled and predictable way. Angular offers two main ways to do this: set() and update(). Each has a distinct purpose and is useful depending on your application's context.
Using set()
The set() method simply replaces the signal's current value with a new value. It's direct and useful when you already know exactly what the new state should be.

Using update()
The update() method, on the other hand, is more idiomatic when you need to compute the new value based on the current value. It takes a function that will run with the signal's current value and must return the desired new value.

This pattern is especially important for maintaining immutability, a practice that helps avoid unwanted side effects and makes it easier to track state changes, something crucial in reactive, complex applications.
Computed Signals
One of the great advantages of Signals in Angular is the ability to create derived values automatically and declaratively, through the computed() function. These Computed Signals are useful when you need to calculate a value based on one or more existing signals and want to make sure that value is always updated automatically when the source data changes.
What is a Computed Signal?
A computed signal is basically a reactive function that depends on other signals. Whenever any of the signals used inside computed() changes, Angular automatically recalculates the new value and propagates that change wherever it's needed.

In the scenario above, potionsInStock is a mutable signal that represents a wizard's magical inventory. totalStockValue is a computed signal that automatically calculates the total in gold coins. If the wizard changes the number of potions or adds a new line to the scroll, the total is recalculated with no manual effort.
Declarative and efficient
The big advantage of using computed() is that it lets you work with derived values in a purely declarative way, without having to worry about manually watching state changes or re-running functions. This reduces code complexity and improves readability.
In addition, Angular handles dependencies intelligently: it automatically tracks which signals were accessed inside computed() and only recalculates it when necessary, keeping the update cycle efficient.
When to use computed()
You should use computed() whenever you have a value that depends on other state but doesn't need to be modified directly. It's ideal for:
- Combining data (e.g. sums, multiplications, concatenation)
- Formatting data for display
- Any data that depends on multiple states and shouldn't be changed directly
Reacting to Changes with Effects
Along with the signals API we have the effect() function, which lets you react automatically to state changes without manually wiring up each update. Like an observable, effect() subscribes automatically to the signals accessed inside it, and it runs whenever any of those values changes.
How effect() works
When you write an effect(), Angular registers every signal read inside it. From then on, whenever one of those signals changes value, the effect runs again, executing the logic inside it. This approach is ideal for handling side effects, such as UI updates, HTTP calls, logging or interactions with external APIs.
Example:

In this example, as soon as the content of the potionsInStock signal changes, whether a new potion is added or quantities are changed, the effect automatically runs again, and the wizard gets an update in the console of his digital grimoire.
Why is this useful?
This behavior is especially useful in scenarios where you need, for example, to:
- Update the user interface dynamically
- Make HTTP calls based on state changes
- Show notifications or conditional messages
- Do automatic logging
With effect(), you no longer need to write extra logic to watch values; Angular takes care of that for you, reactively and automatically.
Conclusion
Signals in modern Angular are here to simplify, once and for all, the way we handle reactivity. With them, you can write cleaner, more organized and easier-to-maintain code.
If you want to see the full examples, I've left the gist link below. If you'd like to chat about it, just reach out:
Examples:
https://gist.github.com/hirowf/7696798d1065d6efd681131dd63b51b5
Source: https://medium.com/@santosant/angular-signals-o-guia-perdido-606232022fd8