Guides
Global dependency graph (MobX-style). Read during compute creates edges. No subscribe API, no use* hooks, no get() ceremony.
| Declaration | Lifetime |
|---|---|
store({…}) at module top | Module lifetime |
let in a function body | Invocation frame — reactive |
const | Not reactive (immutable) |
export const todos = store({
list: [] as Todo[],
filter: "all" as Filter,
get filtered() {
return match this.filter {
"all" => this.list,
"active" => this.list.filter(t => !t.done),
"done" => this.list.filter(t => t.done),
}
},
get remote() async {
return await fetch("/api/todos").then(r => r.json())
},
add(text: string) {
this.list = [...this.list, { id: nanoid(), text, done: false }]
},
})
Default: fine-grained leaf sinks — JSX text/attrs, Show / matchView / mapList, store effect(). Component functions mount once; bare const x = store.y in the body does not re-run the whole component.
Runtime lowers to @preact/signals-core (signal / computed / batch).
Deep dive: docs/02-reactivity.md.