storion 0.7.6 → 0.7.8

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.
package/README.md CHANGED
@@ -986,6 +986,42 @@ function Dashboard({ categoryId }: { categoryId: string }) {
986
986
  3. Empty deps `[]` means "call once and never again"
987
987
  4. `[id]` means "call every time component mounts" (id is unique per mount)
988
988
 
989
+ **Comparison with React Query / Apollo:**
990
+
991
+ | Storion | React Query | Apollo | Behavior |
992
+ | ------------------------------------------ | ----------------------------------------- | ------------------------------------------------ | ----------------------------- |
993
+ | `trigger(fetch, [])` | `useQuery()` | `useQuery()` | Auto-fetch on mount |
994
+ | `trigger(fetch, [id])` | `useQuery({ refetchOnMount: 'always' })` | `useQuery({ fetchPolicy: 'network-only' })` | Fetch every mount |
995
+ | `trigger(fetch, [categoryId], categoryId)` | `useQuery({ variables: { categoryId } })` | `useQuery(QUERY, { variables: { categoryId } })` | Refetch when variable changes |
996
+ | Manual `dispatch()` | `useLazyQuery()` | `useLazyQuery()` | Fetch on user action |
997
+
998
+ ```tsx
999
+ // Auto-fetch (like useQuery in React Query / Apollo)
1000
+ function UserProfile() {
1001
+ const { user } = useStore(({ get }) => {
1002
+ const [state, actions] = get(userStore);
1003
+ trigger(actions.fetchUser, []); // Fetches automatically on mount
1004
+ return { user: state.user };
1005
+ });
1006
+ }
1007
+
1008
+ // Lazy fetch (like useLazyQuery in React Query / Apollo)
1009
+ function SearchResults() {
1010
+ const { results, search } = useStore(({ get }) => {
1011
+ const [state, actions] = get(searchStore);
1012
+ // No trigger - user controls when to fetch
1013
+ return { results: state.results, search: actions.search };
1014
+ });
1015
+
1016
+ return (
1017
+ <div>
1018
+ <button onClick={() => search("query")}>Search</button>
1019
+ {/* results shown after user clicks */}
1020
+ </div>
1021
+ );
1022
+ }
1023
+ ```
1024
+
989
1025
  ### Fine-Grained Updates with pick()
990
1026
 
991
1027
  ```tsx
@@ -1170,8 +1206,8 @@ const userAsync = async(
1170
1206
  },
1171
1207
  {
1172
1208
  retry: { count: 3, delay: 1000 },
1173
- onSuccess: (data) => console.log("Loaded:", data),
1174
1209
  onError: (error) => console.error("Failed:", error),
1210
+ autoCancel: true, // Cancel previous request on new dispatch (default)
1175
1211
  }
1176
1212
  );
1177
1213
 
@@ -1184,12 +1220,13 @@ userAsync.reset(); // Reset to initial state
1184
1220
 
1185
1221
  **Options:**
1186
1222
 
1187
- | Option | Type | Description |
1188
- | ------------- | ------------------------------- | ------------------------ |
1189
- | `retry.count` | `number` | Number of retry attempts |
1190
- | `retry.delay` | `number \| (attempt) => number` | Delay between retries |
1191
- | `onSuccess` | `(data) => void` | Called on success |
1192
- | `onError` | `(error) => void` | Called on error |
1223
+ | Option | Type | Description |
1224
+ | ------------- | ------------------------------- | --------------------------------------------------------- |
1225
+ | `retry` | `number \| AsyncRetryOptions` | Retry configuration |
1226
+ | `retry.count` | `number` | Number of retry attempts |
1227
+ | `retry.delay` | `number \| (attempt) => number` | Delay between retries (ms) |
1228
+ | `onError` | `(error) => void` | Called on error |
1229
+ | `autoCancel` | `boolean` | Cancel previous request on new dispatch (default: `true`) |
1193
1230
 
1194
1231
  **Async helpers:**
1195
1232
 
@@ -1217,6 +1254,43 @@ async.derive(focus, () => {
1217
1254
  });
1218
1255
  ```
1219
1256
 
1257
+ **How `async.wait()` handles each state:**
1258
+
1259
+ | Status | Fresh Mode | Stale Mode |
1260
+ | --------- | ------------------------------ | --------------------- |
1261
+ | `idle` | ❌ Throws `AsyncNotReadyError` | ✅ Returns stale data |
1262
+ | `pending` | ❌ Throws promise (Suspense) | ✅ Returns stale data |
1263
+ | `success` | ✅ Returns data | ✅ Returns data |
1264
+ | `error` | ❌ Throws error | ✅ Returns stale data |
1265
+
1266
+ **Key insight:** In **stale mode**, `async.wait()` always returns the stale data (even during idle/pending/error), so your UI can show previous data while loading. In **fresh mode**, it throws until data is ready.
1267
+
1268
+ ```tsx
1269
+ // Fresh mode - throws on idle, must trigger fetch first
1270
+ const freshState = async.fresh<User>();
1271
+ async.wait(freshState); // ❌ Throws "Cannot wait: state is idle"
1272
+
1273
+ // Stale mode - returns initial data immediately
1274
+ const staleState = async.stale<User[]>([]);
1275
+ async.wait(staleState); // ✅ Returns [] (the initial data)
1276
+ ```
1277
+
1278
+ **`async.all()` follows the same rules** — it calls `async.wait()` on each state:
1279
+
1280
+ ```tsx
1281
+ // All stale mode - returns immediately with stale data
1282
+ const [users, posts] = async.all(
1283
+ async.stale<User[]>([]), // Returns []
1284
+ async.stale<Post[]>([]) // Returns []
1285
+ );
1286
+
1287
+ // Mixed mode - throws if any fresh state is not ready
1288
+ const [user, posts] = async.all(
1289
+ async.fresh<User>(), // ❌ Throws - idle fresh state
1290
+ async.stale<Post[]>([])
1291
+ );
1292
+ ```
1293
+
1220
1294
  ### pick(fn, equality?)
1221
1295
 
1222
1296
  Fine-grained value tracking.
@@ -1306,9 +1380,14 @@ const persistMiddleware: StoreMiddleware = (ctx) => {
1306
1380
  return instance;
1307
1381
  };
1308
1382
 
1309
- // Apply conditionally
1383
+ // Apply single middleware
1310
1384
  const app = container({
1311
- middleware: compose(
1385
+ middleware: loggingMiddleware,
1386
+ });
1387
+
1388
+ // Apply multiple middlewares (array)
1389
+ const app = container({
1390
+ middleware: [
1312
1391
  // Apply to stores starting with "user"
1313
1392
  applyFor("user*", loggingMiddleware),
1314
1393
 
@@ -1319,8 +1398,8 @@ const app = container({
1319
1398
  applyFor(["authStore", "settingsStore"], loggingMiddleware),
1320
1399
 
1321
1400
  // Apply based on condition
1322
- applyFor((ctx) => ctx.spec.options.meta?.debug === true, loggingMiddleware)
1323
- ),
1401
+ applyFor((ctx) => ctx.spec.options.meta?.debug === true, loggingMiddleware),
1402
+ ],
1324
1403
  });
1325
1404
  ```
1326
1405
 
@@ -1374,9 +1453,21 @@ const myStore = store({
1374
1453
  | Arguments | None | Supports extra args |
1375
1454
  | Use case | Shared services | Configured instances |
1376
1455
 
1377
- ### Store-Level Equality
1456
+ ### Equality Strategies
1457
+
1458
+ Storion supports equality checks at **two levels**, giving you fine-grained control over when updates happen.
1378
1459
 
1379
- Configure how state changes are detected:
1460
+ **Comparison with other libraries:**
1461
+
1462
+ | Library | Store-level equality | Selector-level equality |
1463
+ | ----------- | -------------------- | -------------------------------------- |
1464
+ | **Redux** | ❌ No | ✅ `useSelector(selector, equalityFn)` |
1465
+ | **Zustand** | ❌ No | ✅ `useStore(selector, shallow)` |
1466
+ | **Jotai** | ✅ Per-atom | ❌ No |
1467
+ | **MobX** | ✅ Deep by default | ❌ No (computed) |
1468
+ | **Storion** | ✅ Per-property | ✅ `pick(fn, equality)` |
1469
+
1470
+ **Store-level equality** — Prevents notifications when state "changes" to an equivalent value:
1380
1471
 
1381
1472
  ```ts
1382
1473
  const mapStore = store({
@@ -1406,6 +1497,73 @@ const mapStore = store({
1406
1497
  });
1407
1498
  ```
1408
1499
 
1500
+ **Selector-level equality** — Prevents re-renders when selected value hasn't changed:
1501
+
1502
+ ```tsx
1503
+ function MapView() {
1504
+ const { x, coords, markers } = useStore(({ get }) => {
1505
+ const [state] = get(mapStore);
1506
+ return {
1507
+ // Only re-render if x specifically changed
1508
+ x: pick(() => state.coords.x),
1509
+
1510
+ // Only re-render if coords object is shallow-different
1511
+ coords: pick(() => state.coords, "shallow"),
1512
+
1513
+ // Custom comparison at selector level
1514
+ markers: pick(
1515
+ () => state.markers.map((m) => m.id),
1516
+ (a, b) => a.join() === b.join()
1517
+ ),
1518
+ };
1519
+ });
1520
+ }
1521
+ ```
1522
+
1523
+ **When to use each:**
1524
+
1525
+ | Level | When it runs | Use case |
1526
+ | ------------------ | --------------------- | ---------------------------------------------------- |
1527
+ | **Store-level** | On every state write | Prevent unnecessary notifications to ALL subscribers |
1528
+ | **Selector-level** | On every selector run | Prevent re-renders for THIS component only |
1529
+
1530
+ ```
1531
+ ┌─────────────────────────────────────────────────────────────────────┐
1532
+ │ state.coords = { x: 1, y: 2 } │
1533
+ │ │ │
1534
+ │ ▼ │
1535
+ │ Store-level equality: coords: "shallow" │
1536
+ │ Same x and y values? → Skip notifying ALL subscribers │
1537
+ │ │ │
1538
+ │ ▼ (if changed) │
1539
+ │ ┌─────────────────────┐ ┌─────────────────────┐ │
1540
+ │ │ Component A │ │ Component B │ │
1541
+ │ │ pick(() => coords.x)│ │ pick(() => coords) │ │
1542
+ │ │ │ │ │ │ │ │
1543
+ │ │ ▼ │ │ ▼ │ │
1544
+ │ │ Re-render if x │ │ Re-render if x OR y │ │
1545
+ │ │ changed │ │ changed │ │
1546
+ │ └─────────────────────┘ └─────────────────────┘ │
1547
+ └─────────────────────────────────────────────────────────────────────┘
1548
+ ```
1549
+
1550
+ **Why Storion's approach is powerful:**
1551
+
1552
+ ```tsx
1553
+ // Redux/Zustand - must remember to add equality every time
1554
+ const coords = useSelector((state) => state.coords, shallowEqual);
1555
+ const coords = useStore((state) => state.coords, shallow);
1556
+
1557
+ // Storion - store-level handles common cases, pick() for fine-tuning
1558
+ const mapStore = store({
1559
+ equality: { coords: "shallow" }, // Set once, applies everywhere
1560
+ // ...
1561
+ });
1562
+
1563
+ // Components can add extra precision with pick()
1564
+ const x = pick(() => state.coords.x); // Even finer control
1565
+ ```
1566
+
1409
1567
  ### Testing with Mocks
1410
1568
 
1411
1569
  ```ts
@@ -1476,6 +1634,8 @@ const myStore = store({
1476
1634
 
1477
1635
  ### DevTools Integration
1478
1636
 
1637
+ ![Storion DevTools](https://raw.githubusercontent.com/linq2js/storion/main/packages/storion/img/image.png)
1638
+
1479
1639
  ```ts
1480
1640
  import { devtools } from "storion/devtools";
1481
1641
 
@@ -1528,6 +1688,25 @@ const myStore = store({
1528
1688
  });
1529
1689
  ```
1530
1690
 
1691
+ **Important:** Even if an effect throws an error, it **still re-runs** when its tracked states change. The effect keeps its dependency tracking from before the error occurred.
1692
+
1693
+ ```ts
1694
+ effect(() => {
1695
+ console.log("Effect running, count:", state.count); // Tracks `count`
1696
+
1697
+ if (state.count > 5) {
1698
+ throw new Error("Count too high!");
1699
+ }
1700
+ });
1701
+
1702
+ // Later...
1703
+ state.count = 10; // Effect re-runs, throws error, calls onError
1704
+ state.count = 3; // Effect re-runs again, no error this time
1705
+ state.count = 8; // Effect re-runs, throws error again
1706
+ ```
1707
+
1708
+ This behavior ensures that effects can recover when state returns to a valid condition.
1709
+
1531
1710
  ### Async Errors
1532
1711
 
1533
1712
  ```ts
@@ -1 +1 @@
1
- {"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/async/async.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EAET,YAAY,EACZ,YAAY,EACZ,YAAY,EAEZ,kBAAkB,EAElB,cAAc,EAEd,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,cAAc,EAEf,MAAM,SAAS,CAAC;AAUjB;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,GACxB,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,CAKxB;AAID;;;GAGG;AACH,iBAAS,UAAU,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAIxE;AAuDD,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,SAAS,EAAE,KAAK,SAAS,GAAG,EAAE,EAC/D,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAC9B,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,KAAK,CAAC,EAC/B,OAAO,CAAC,EAAE,YAAY,GACrB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAkU3B;AAMD;;;GAGG;AACH,UAAU,eAAe,CAAC,CAAC;IACzB,KAAK,CAAC,EAA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AAC,CAAC,GACtB,KAAK,IAAI,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,KAAK,CAAA;KAAE,CAE/D;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+CG;IACH,SAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,SAAS,GAAG,OAAO,EACrD,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAC9B,SAAS,EAAE,MAAM,CAAC,GACjB,YAAY,CAoDd;CACF"}
@@ -429,10 +429,8 @@ asyncState.from = asyncStateFrom;
429
429
  throw promise;
430
430
  }
431
431
  }
432
- throw new AsyncNotReadyError(
433
- `Cannot wait: state is ${state.status}`,
434
- state.status
435
- );
432
+ const message = state.status === "idle" ? `Cannot wait: state is idle. Call dispatch() or use trigger() to start the async operation before calling async.wait().` : `Cannot wait: state is ${state.status}`;
433
+ throw new AsyncNotReadyError(message, state.status);
436
434
  }
437
435
  async2.wait = wait;
438
436
  function race(states) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storion",
3
- "version": "0.7.6",
3
+ "version": "0.7.8",
4
4
  "description": "Reactive stores for modern apps. Type-safe. Auto-tracked. Effortlessly composable",
5
5
  "type": "module",
6
6
  "main": "./dist/storion.js",
@@ -46,9 +46,9 @@
46
46
  "version:minor": "npm version minor -m \"chore: bump version to %s\"",
47
47
  "version:major": "npm version major -m \"chore: bump version to %s\"",
48
48
  "prepublishOnly": "pnpm run build",
49
- "release:patch": "git status --porcelain | grep -q . && echo 'Error: uncommitted changes' && exit 1; pnpm version:patch && git add -A && git commit --amend --no-edit && npm publish",
50
- "release:minor": "git status --porcelain | grep -q . && echo 'Error: uncommitted changes' && exit 1; pnpm version:minor && git add -A && git commit --amend --no-edit && npm publish",
51
- "release:major": "git status --porcelain | grep -q . && echo 'Error: uncommitted changes' && exit 1; pnpm version:major && git add -A && git commit --amend --no-edit && npm publish",
49
+ "release:patch": "git status --porcelain | grep -q . && echo 'Error: uncommitted changes' && exit 1; pnpm version:patch && git add -A && git commit -m 'chore: release patch' && git push && npm publish",
50
+ "release:minor": "git status --porcelain | grep -q . && echo 'Error: uncommitted changes' && exit 1; pnpm version:minor && git add -A && git commit -m 'chore: release minor' && git push && npm publish",
51
+ "release:major": "git status --porcelain | grep -q . && echo 'Error: uncommitted changes' && exit 1; pnpm version:major && git add -A && git commit -m 'chore: release major' && git push && npm publish",
52
52
  "publish:dry": "npm publish --dry-run"
53
53
  },
54
54
  "keywords": [