stoic-store 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +53 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Stoic
2
+
3
+ Tiny React state manager with reactive derived state.
4
+
5
+ No reducers • No dependency arrays • No boilerplate • Fully typed • Plugin-based
6
+
7
+ Stoic is a small state management library for React, built on `useSyncExternalStore`. You define state and actions much like you would with any store library, but Stoic also lets you declare **derived state** — values computed from other state — as part of the store itself. Only the derived values and components that actually depend on a change are recomputed and rerendered.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install stoic-store
13
+ ```
14
+
15
+ Stoic requires React 18 or later.
16
+
17
+ ## Quick Start
18
+
19
+ ```ts
20
+ import { createStore } from "stoic-store";
21
+
22
+ export const cart = createStore({
23
+ state: {
24
+ items: [{ id: 1, title: "Keyboard", price: 100 }],
25
+ tax: 0.2,
26
+ },
27
+
28
+ derived: {
29
+ subtotal: ({ items }) => items.reduce((sum, item) => sum + item.price, 0),
30
+ total: ({ subtotal, tax }) => subtotal * (1 + tax),
31
+ },
32
+ });
33
+
34
+ export const { setTax } = cart.actions({
35
+ setTax: (setState, tax: number) => setState({ tax }),
36
+ });
37
+ ```
38
+
39
+ ```tsx
40
+ function CartSummary() {
41
+ const total = cart.useStore((state) => state.total);
42
+
43
+ return <h2>Total: ${total}</h2>;
44
+ }
45
+ ```
46
+
47
+ ## Documentation
48
+
49
+ Full docs, including derived state, async actions, and plugins (`persist` and writing your own), are in the [project README](https://github.com/peakercope/stoic#readme).
50
+
51
+ ## License
52
+
53
+ MIT
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stoic-store",
3
3
  "type": "module",
4
- "version": "0.0.1",
4
+ "version": "0.0.2",
5
5
  "description": "Minimal and powerful React state manager. Tiny, intuitive, and fully TypeScript-ready.",
6
6
  "author": "peakercope <peakercope@gmail.com> (https://github.com/peakercope)",
7
7
  "license": "MIT",