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:
- When you create
signal(0), Angular makes an internal store with the value0. - When you call
counter(), you read that value. - 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 readyPremium
A concise answer to help you respond confidently on this topic during an interview.