Interface: SignalState<T>
API / @xmachines/play-signals / SignalState
Defined in: packages/play-signals/src/types.ts:54
The writable state signal. It holds one reactive value
Signal.State is the base primitive of a reactive state. A get() call inside a
computed signal or inside a watcher tracks the state as a dependency. A set()
call notifies every computation and every watcher that depends on the state.
Example
import { Signal } from "@xmachines/play-signals";
const name = new Signal.State("Alice");console.log(name.get()); // 'Alice'name.set("Bob");console.log(name.get()); // 'Bob'Type Parameters
| Type Parameter |
|---|
T |
Methods
get()
get(): T;Defined in: packages/play-signals/src/types.ts:60
Reads the current value, and tracks the signal as a dependency
Returns
T
The current value of the signal
set()
set(value): void;Defined in: packages/play-signals/src/types.ts:67
Writes a new value, and notifies the watchers when the value changed
Parameters
| Parameter | Type | Description |
|---|---|---|
value | T | The new value |
Returns
void