@zerolith/state
v1.5.0
Published
Signals with a memory for zerolith: a signal kept in storage and across tabs, undo and redo, debounced and throttled signals, and a row selector
Maintainers
Readme
@zerolith/state
Signals with a memory, over the core alone: a signal kept in storage and across tabs, undo and redo for a signal, debounced and throttled signals, and a selector that tells each row whether it is the selected one.
import { signal } from "zerolith";
import { debounced, history, selector, stored } from "@zerolith/state";
const theme = stored<"light" | "dark">("theme", "light");
const edits = history(signal(""));
const settledQuery = debounced(signal(""), 300);
const selected = selector(signal<number | null>(null));storedreads its value from storage as JSON, writes every set, and follows other tabs.historygivescheckpoint(),undo(), andredo(), withcanUndoandcanRedoas signals.debouncedandthrottledfollow a signal after a quiet spell or at most so often.selectorgives each key a signal that is true for the selected one, so a selection among a thousand rows updates two.
The guide is on the docs site.
Install with npm install @zerolith/state. The API is frozen at 1.0: a breaking change comes only in a major, after a deprecation notice, and the support policy says how long a line gets fixes.
Documentation
- The state guide explains it with examples that run as tests.
- The reference lists every export, generated from the source.
- New to zerolith? The tutorial builds an app step by step, and the playground runs code in the browser.
License
Apache-2.0. See LICENSE.
