Function
signal
The type of the value held by the signal.
Optional
Initial value stored by the signal.
The object to bind the signal to. Omit it for a free-standing signal.
The key path at which the signal is stored in the target.
A reactive box for reading and updating the value.
Create a standalone reactive signal from an initial value.
const count = signal(0);const nested = signal(0, target, "users", "42", "score"); Copy
const count = signal(0);const nested = signal(0, target, "users", "42", "score");
Getter that returns the value.
Setter that changes the value and emits the signal.
Create a standalone reactive signal backed by an existing getter and setter, rather than by its own storage. Use it to make a value that already lives somewhere else reactive.
const nested = signal(() => target.get("users", "42"), v => target.set(v, "users", "42"), target, "users", "42"); Copy
const nested = signal(() => target.get("users", "42"), v => target.set(v, "users", "42"), target, "users", "42");
Stage-3 decorator that turns a field, getter, setter, or accessor into a reactive signal.
class Counter { @signal count = 0; @effect log() { console.log(this.count); }}const c = new Counter();c.count++; // triggers effect, logs updated value Copy
class Counter { @signal count = 0; @effect log() { console.log(this.count); }}const c = new Counter();c.count++; // triggers effect, logs updated value
signal