@menapo/store
v0.1.1
Published
Client state for kit apps: store({ … }) is an object literal, writes are assignments, and useStore re-renders a component only for the keys it read, in every framework
Readme
@menapo/store
Client state for kit apps: a store is an object literal, writes are
assignments, and useStore re-renders a component only for the keys it
read, in React, Preact, Vue, Svelte, Solid and plain code. No selectors,
no key lists, no proxies.
Status: built, private until 1.0. store with derived values tracked
across stores, batch, subscribe, reset, persist with localStorage
or cookies(), /server's withStores, /test, the plugin (glue for six
frameworks, names, HMR, the DevTools panel) and four helpers, each its own
entry (/theme, /media, /selection, /debounced), are implemented and tested;
examples/store-react drives React and Vue over the same stores in
Chromium. The release waits on the owner's review.
import { store } from "@menapo/store";
export const ui = store({ sidebar: true, density: "comfortable" as "comfortable" | "compact" });
ui.sidebar = false; // views that read `sidebar` update, nothing elseconst u = useStore(ui);
<aside hidden={!u.sidebar} data-density={u.density}>
…
</aside>;- Guide: where state belongs, then stores, components, persistence, servers, tests and DevTools.
- Plan: the design, its decisions and measurements.
- Benchmarks:
vp run --filter @menapo/bench bench:store(bench/README.md).
