Skip to main content

How to make a chain of computed signals? (junior)

A chain of computed signals is when one computed() uses another inside itself. Everything works automatically: Angular tracks the dependencies on its own.

Example:

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

How it works:

  • total() calculates price * count
  • withTax() calculates total * 1.2
  • if price or count changes, both total and withTax update, in the correct order

Important: you do not need to tell Angular what to recompute, it builds the chain itself and updates everything necessary.

This way you can build any level of logic: from simple values to complex computations with dependencies.

Short Answer

Interview ready
Premium

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