@formwright/reactive
v0.13.1
Published
Tiny zero-dependency fine-grained signal engine shared by Formwright and Gridwright.
Readme
@formwright/reactive
Tiny, dependency-free signals shared by Formwright, Gridwright, and Overlaywright.
npm install @formwright/reactiveQuick start
import { batch, computed, effect, signal } from "@formwright/reactive";
const firstName = signal("Ada");
const lastName = signal("Lovelace");
const fullName = computed(() => `${firstName.get()} ${lastName.get()}`);
const stop = effect(() => {
console.log(fullName.get());
});
batch(() => {
firstName.set("Grace");
lastName.set("Hopper");
});
stop();Effects run immediately and update synchronously. Computed values are lazy and cached. Use untrack to read without subscribing and dispose every long-lived effect when its owner is destroyed.
API
signal(initial)— writable reactive valuecomputed(fn)— lazy derived valueeffect(fn)— reactive side effect with optional cleanupbatch(fn)— group writes into one effect flushuntrack(fn)— read without recording dependenciesisTracking()— detect an active reactive context
License
MIT
