Whisq v0.1.0-alpha.9
signal()
Create a reactive value that triggers updates when changed.
Signature
Section titled “Signature”function signal<T>(initialValue: T): Signal<T>Parameters
Section titled “Parameters”| Param | Type | Description |
|---|---|---|
initialValue | T | The initial value |
Returns
Section titled “Returns”Signal<T> with:
| Property | Type | Description |
|---|---|---|
.value | T | Read or write (triggers reactivity) |
.peek() | T | Read without tracking |
.set(value) | void | Set a new value |
.update(fn) | void | Update via function |
.subscribe(fn) | () => void | Subscribe to changes, returns unsubscribe |
Examples
Section titled “Examples”import { signal } from "@whisq/core";
const count = signal(0);count.value; // 0 (read — triggers tracking)count.value = 5; // (write — triggers updates)count.update(n => n + 1); // 6count.peek(); // 6 (read — no tracking)Related primitives
Section titled “Related primitives”computed()— derived values (read-only signals that recompute when their inputs change).effect()— run side effects when tracked signals change.batch()— group multiple writes into one notification.persistedSignal()— aSignal<T>backed bylocalStorage/sessionStorage(sub-path import).signalMap(),signalSet()— reactive collections with per-key / per-value subscriptions.partition()— split a signal-held array into matching / not-matching derived signals.
Docs current to v0.1.0-alpha.9 . All releases →