Skip to main content

What is a computed() signal?

computed() is a way to create a signal that stores nothing itself but always recomputes its value from other signals.

To put it simply:

  • signal() stores data
  • computed() calculates data from other signals

Example:

ts
import { signal, computed } from '@angular/core'; const price = signal(100); const count = signal(2); const total = computed(() => price() * count());

Now total() will always show the correct sum. If price or count changes, total recomputes itself.

The main point:

  • computed() never changes anything manually
  • It only calculates based on other signals
  • It works like a formula in Excel: something changes in a cell, and everything that depends on it recalculates

This is convenient when you need to automatically get a new value without extra code.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.