What is WritableSignal?
WritableSignal is the type of a signal that can be changed. It allows not only reading the value but also changing it via set() and update().
To put it simply, for a junior:
signal()→ creates a WritableSignal- such a signal can be read (
counter()) - and written (
counter.set(...)orcounter.update(...))
Example:
ts
import { signal, WritableSignal } from '@angular/core';
const counter: WritableSignal<number> = signal(0);
counter(); // read
counter.set(10); // set a new value
counter.update(v => v + 1); // change based on the old oneSo WritableSignal is an ordinary signal that holds a value and allows it to be changed.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.