Updating Signals with set and update
Change signal values reactively.
Changing a Signal
A writable signal can be changed in two ways: set() to replace the value, and update() to derive a new value from the current one.
Using set()
set(newValue) replaces the signal value entirely with the value you pass.
const c = signal(0);
c.set(1);
console.log(c()); // 1All lessons in this course
- What Are Signals
- Creating and Reading Signals
- Updating Signals with set and update
- Signals in Templates