Skip to main content

How does a signal store state?

A signal stores state inside itself, like an ordinary variable, but with reactive "observation" of changes.

Step by step:

  1. When you create signal(0), Angular makes an internal store with the value 0.
  2. When you call counter(), you read that value.
  3. When you do counter.set(5), Angular updates the internal store and notifies all the dependent parts that the data has changed.

So a signal is a variable with memory and built-in reactivity: it remembers its state and knows on its own who needs to be notified about changes.

Short Answer

Interview ready
Premium

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