Course lesson
Create an Angular Computed Signal Which Depends on Another Signal
Computed signals in Angular allow for the creation of derived values based on existing signals. By defining a new property and assigning it a computed signal, you can perform calculations or transformations on top of an existing signal's value.
- Duration
- 4 min
- Access
- Free
- Transcript
- Retained from source evidence
Computed signals in Angular allow for the creation of derived values based on existing signals. By defining a new property and assigning it a computed signal, you can perform calculations or transformations on top of an existing signal's value.
To create a computed signal that remains responsive to changes in its dependencies, it's essential to:
- Define the computed signal's callback function, which calculates the derived value based on other signals
- Ensure that the computed signal is consumed by a live consumer, such as a template, to trigger re-evaluation when dependencies change
The reactivity flow in Angular ensures that whenever a dependency of a computed signal changes, the computed value is automatically re-evaluated. This re-evaluation only occurs if there is a live consumer, such as a template, that depends on the computed signal.