storion 0.10.1 → 0.10.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 +78 -104
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  <h1 align="center">Storion</h1>
6
6
 
7
7
  <p align="center">
8
- <strong>Reactive state management with automatic dependency tracking</strong>
8
+ <strong>State management that gets out of your way</strong>
9
9
  </p>
10
10
 
11
11
  <p align="center">
@@ -24,134 +24,108 @@
24
24
 
25
25
  ---
26
26
 
27
- ## Why Storion?
28
-
29
- **Simple at first. Powerful as you grow.**
30
-
31
- Start with basic stores and direct mutations. As your app grows, layer in async state, effects, dependency injection, and middleware — all without rewriting existing code.
32
-
33
- ## Features
34
-
35
- | | |
36
- | -------------------- | ---------------------------------------- |
37
- | 🎯 **Auto-tracking** | Dependencies tracked when you read state |
38
- | ⚡ **Fine-grained** | Only re-render what changed |
39
- | 🔒 **Type-safe** | Full TypeScript with excellent inference |
40
- | 📦 **Tiny** | ~4KB minified + gzipped |
41
- | ⏳ **Async** | First-class loading states with Suspense |
42
- | 🛠️ **DevTools** | Built-in debugging panel |
43
-
44
- ## Installation
45
-
46
- ```bash
47
- npm install storion
48
- ```
49
-
50
- ## Quick Start
51
-
52
- **Read state → Storion tracks it. State changes → Only affected components re-render.**
27
+ ## The Simplest Counter You'll Ever Write
53
28
 
54
29
  ```tsx
55
30
  import { create } from "storion/react";
56
31
 
57
- // Create store and hook in one call - no Provider needed!
58
- const [counter, useCounter] = create({
32
+ const [_, useCounter] = create({
59
33
  state: { count: 0 },
60
- setup({ state }) {
61
- return {
62
- inc: () => state.count++,
63
- dec: () => state.count--,
64
- };
65
- },
34
+ setup: ({ state }) => ({
35
+ inc: () => state.count++,
36
+ dec: () => state.count--,
37
+ }),
66
38
  });
67
39
 
68
40
  function Counter() {
69
- const { count, inc, dec } = useCounter((state, actions) => ({
70
- count: state.count,
71
- ...actions,
72
- }));
73
-
74
- return (
75
- <div>
76
- <button onClick={dec}>-</button>
77
- <span>{count}</span>
78
- <button onClick={inc}>+</button>
79
- </div>
80
- );
41
+ const { count, inc, dec } = useCounter((s, a) => ({ count: s.count, ...a }));
42
+ return <button onClick={inc}>{count}</button>;
81
43
  }
82
44
  ```
83
45
 
84
- <details>
85
- <summary>Multi-store apps with StoreProvider</summary>
46
+ **That's it.** No Provider. No boilerplate. No ceremony.
86
47
 
87
- ```tsx
88
- import { store, useStore, StoreProvider } from "storion/react";
48
+ ---
89
49
 
90
- const counterStore = store({
91
- name: "counter",
92
- state: { count: 0 },
93
- setup({ state }) {
94
- return {
95
- inc: () => state.count++,
96
- dec: () => state.count--,
97
- };
98
- },
99
- });
50
+ ## Why Storion?
100
51
 
101
- function Counter() {
102
- const { count, inc, dec } = useStore(({ get }) => {
103
- const [state, actions] = get(counterStore);
104
- return { count: state.count, ...actions };
105
- });
106
-
107
- return (
108
- <div>
109
- <button onClick={dec}>-</button>
110
- <span>{count}</span>
111
- <button onClick={inc}>+</button>
112
- </div>
113
- );
114
- }
52
+ | Pain Point | Storion's Answer |
53
+ | ------------------------- | ----------------------------------------------- |
54
+ | 🤯 Too much boilerplate | One `create()` call. Done. |
55
+ | 🐌 Unnecessary re-renders | Auto-tracks what you read, updates only that |
56
+ | 😵 Complex async handling | Built-in loading states, cancellation, Suspense |
57
+ | 🔧 Provider hell | Optional. Use it when you need it |
58
+ | 📦 Bundle anxiety | ~4KB gzipped. Seriously. |
59
+
60
+ ---
61
+
62
+ ## Features at a Glance
115
63
 
116
- function App() {
117
- return (
118
- <StoreProvider>
119
- <Counter />
120
- </StoreProvider>
121
- );
122
- }
123
64
  ```
65
+ ✦ Auto-tracking Read state → automatically subscribed
66
+ ✦ Fine-grained Change count? Only Counter re-renders
67
+ ✦ Type-safe Full inference, zero manual types
68
+ ✦ Async-first Loading, error, stale states built-in
69
+ ✦ DevTools Time-travel debugging included
70
+ ✦ Scalable From counter to enterprise, same API
71
+ ```
72
+
73
+ ---
124
74
 
125
- </details>
75
+ ## Growing With You
126
76
 
127
- ## Async State
77
+ **Start simple:**
128
78
 
129
79
  ```tsx
130
- import { async } from "storion/async";
131
-
132
- const userStore = store({
133
- name: "user",
134
- state: { user: async.fresh<User>() },
135
- setup({ focus }) {
136
- const userQuery = async.action(focus("user"), async (ctx, id: string) => {
137
- const res = await fetch(`/api/users/${id}`, { signal: ctx.signal });
138
- return res.json();
139
- });
140
-
141
- return { fetchUser: userQuery.dispatch };
80
+ const [_, useAuth] = create({
81
+ state: { user: null },
82
+ setup: ({ state }) => ({
83
+ login: (user) => {
84
+ state.user = user;
85
+ },
86
+ logout: () => {
87
+ state.user = null;
88
+ },
89
+ }),
90
+ });
91
+ ```
92
+
93
+ **Add async when ready:**
94
+
95
+ ```tsx
96
+ const [_, useUsers] = create({
97
+ state: { users: async.stale([]) },
98
+ setup: ({ focus }) => {
99
+ const query = async(focus("users"), (ctx) =>
100
+ fetch("/api/users", { signal: ctx.signal }).then((r) => r.json())
101
+ );
102
+ return { fetch: query.dispatch, refresh: query.refresh };
142
103
  },
143
104
  });
144
105
  ```
145
106
 
146
- ## Learn More
107
+ **Scale to multi-store apps:**
147
108
 
148
- 📚 **[Full Documentation](https://linq2js.github.io/storion/)** — Guides, examples, and API reference
109
+ ```tsx
110
+ // When you need shared containers, dependency injection, middleware...
111
+ <StoreProvider>
112
+ <App />
113
+ </StoreProvider>
114
+ ```
115
+
116
+ ---
149
117
 
150
- - [Getting Started](https://linq2js.github.io/storion/guide/getting-started.html)
151
- - [Core Concepts](https://linq2js.github.io/storion/guide/core-concepts.html)
152
- - [Async State](https://linq2js.github.io/storion/guide/async.html)
153
- - [API Reference](https://linq2js.github.io/storion/api/store.html)
154
- - [Live Demos](https://linq2js.github.io/storion/demos.html)
118
+ ## Documentation
119
+
120
+ 📚 **[Full Documentation](https://linq2js.github.io/storion/)** — Everything you need
121
+
122
+ - [Getting Started](https://linq2js.github.io/storion/guide/getting-started.html) — 5 min setup
123
+ - [Core Concepts](https://linq2js.github.io/storion/guide/core-concepts.html) — How it works
124
+ - [Async State](https://linq2js.github.io/storion/guide/async.html) — Loading states made easy
125
+ - [API Reference](https://linq2js.github.io/storion/api/store.html) — Every function documented
126
+ - [Live Demos](https://linq2js.github.io/storion/demos.html) — See it in action
127
+
128
+ ---
155
129
 
156
130
  ## License
157
131
 
@@ -160,5 +134,5 @@ MIT © [linq2js](https://github.com/linq2js)
160
134
  ---
161
135
 
162
136
  <p align="center">
163
- <sub>Built with ❤️ for the React community</sub>
137
+ <sub>Built with ❤️ for developers who value simplicity</sub>
164
138
  </p>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storion",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "description": "Reactive stores for modern apps. Type-safe. Auto-tracked. Effortlessly composable",
5
5
  "type": "module",
6
6
  "main": "./dist/storion.js",