All topics
Stateintermediate

Computed Signals

Explain how computed() derives a memoized, automatically-updating value from other signals.

computed() creates a read-only Signal whose value is derived from other Signals via a pure function, and it exists to solve the same problem memoized getters or useMemo-style hooks solve in other frameworks: avoiding redundant recalculation of a derived value on every single change detection cycle, while still keeping that derived value automatically, correctly up to date whenever any of its actual dependencies change.

It's like a restaurant's daily specials board that's only rewritten when the kitchen actually changes what's available — not every time a customer glances at it — so the sign accurately reflects reality without a staff member repainting it after every single glance.

Key Concepts

1
The key mechanism is automatic dependency tracking: you don't declare which Signals a computed() depends on — Angular figures it out by observing which Signals were actually read (called) during the computed function's execution, and only those specific Signals become tracked dependencies. This means a computed() that conditionally reads different Signals depending on a branch will only depend on whichever ones were actually touched during the most recent evaluation, which is a subtlety worth mentioning in a deep-dive interview answer.
computed()
2
Critically, computed() values are memoized/cached — the derivation function only re-runs when one of its tracked dependencies actually changes, not on every read, so reading the same computed() signal repeatedly between actual dependency changes is cheap, just returning the cached value rather than re-executing the function each time.
computed()
3
A good interview answer draws the direct parallel to getter methods on a component class as often computed elsewhere in Angular tutorials: a plain getter re-executes its logic every single time it's accessed (including every single change detection check, whether or not its inputs actually changed), which can be a real performance problem for expensive derivations, whereas computed() explicitly avoids that redundant recomputation through its dependency-tracked memoization — a concrete, comparison-based way to demonstrate you understand *why* computed signals exist, not just their syntax.
gettercomputed()