chrono-state-z 2.1.0 → 2.2.1-iz
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 +122 -32
- package/build/index.cjs.js +1 -1
- package/build/index.d.ts +9 -3
- package/build/index.esm.js +1 -1
- package/build/react/schedule.d.ts +1 -1
- package/build/react/useBatch.d.ts +1 -1
- package/build/react/useComputed.d.ts +2 -1
- package/build/react/useEffectReact.d.ts +1 -1
- package/build/react/useWatch.d.ts +2 -1
- package/package.json +11 -28
- package/build/core/asyncAtom.d.ts +0 -9
- package/build/core/asyncComputed.d.ts +0 -6
- package/build/core/atom.d.ts +0 -6
- package/build/core/computed.d.ts +0 -1
- package/build/core/createStore.d.ts +0 -3
- package/build/core/effect.d.ts +0 -2
- package/build/core/effectContext.d.ts +0 -3
- package/build/core/factoryAtom.d.ts +0 -1
- package/build/core/graph.d.ts +0 -22
- package/build/core/index.d.ts +0 -10
- package/build/core/selector.d.ts +0 -7
- package/build/core/store.d.ts +0 -12
- package/build/core/transaction.d.ts +0 -1
- package/build/core/watch.d.ts +0 -2
package/README.md
CHANGED
|
@@ -6,18 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
**chrono-state-z** is a
|
|
9
|
+
**chrono-state-z** is a reactive state runtime that keeps business logic outside React.
|
|
10
|
+
It provides **atoms, computed values, async state, effects, scheduling**, with a **headless core** and **thin React bindings**.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
> **React renders state. Logic lives elsewhere.**
|
|
12
|
+
> **React renders. Logic lives elsewhere.**
|
|
14
13
|
|
|
15
14
|
---
|
|
16
15
|
|
|
17
16
|
## ✨ Why chrono-state-z?
|
|
18
17
|
|
|
19
|
-
Use chrono-state-z when you need:
|
|
20
|
-
|
|
21
18
|
- Predictable state & side-effects
|
|
22
19
|
- Complex async flows (fetch → invalidate → retry)
|
|
23
20
|
- Logic reusable outside React (tests, workers, backend)
|
|
@@ -28,23 +25,61 @@ Use chrono-state-z when you need:
|
|
|
28
25
|
|
|
29
26
|
## 🧠 Mental Model
|
|
30
27
|
|
|
31
|
-
- Atom
|
|
32
|
-
- Computed
|
|
33
|
-
- AsyncAtom
|
|
34
|
-
- Effect
|
|
35
|
-
-
|
|
36
|
-
- Store / Intent
|
|
37
|
-
- React hooks
|
|
28
|
+
- **Atom** → small reactive state unit
|
|
29
|
+
- **Computed** → derived, cached reactive value
|
|
30
|
+
- **AsyncAtom** → async resource with invalidate + priority
|
|
31
|
+
- **Effect** → reactive side-effect runner
|
|
32
|
+
- **Transaction** → batch updates
|
|
33
|
+
- **Store / Intent** → event-driven orchestration
|
|
34
|
+
- **React hooks** → thin bindings over the headless core
|
|
38
35
|
|
|
39
36
|
---
|
|
40
37
|
|
|
41
38
|
## 📦 Installation
|
|
42
39
|
|
|
43
40
|
```bash
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
npm install chrono-state-z
|
|
42
|
+
# If using React:
|
|
43
|
+
npm install react
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## ⚡ Quick Start
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { atom, computed, asyncAtom } from "chrono-state-z";
|
|
52
|
+
|
|
53
|
+
const count = atom(0);
|
|
54
|
+
const double = computed(() => count() * 2);
|
|
55
|
+
|
|
56
|
+
const user = asyncAtom(async () =>
|
|
57
|
+
fetch("https://jsonplaceholder.typicode.com/todos/1")
|
|
58
|
+
.then(r => r.json())
|
|
59
|
+
);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { useAtom, useComputed } from "chrono-state-z";
|
|
64
|
+
|
|
65
|
+
function App() {
|
|
66
|
+
const value = useAtom(count);
|
|
67
|
+
const doubled = useComputed(double);
|
|
68
|
+
const username = useComputed(() => user()?.title);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<button onClick={() => count.set(c => c + 1)}>
|
|
72
|
+
{value}
|
|
73
|
+
</button>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
46
77
|
```
|
|
47
78
|
|
|
79
|
+
✨ Fine-grained updates.
|
|
80
|
+
✨ Suspense-ready async.
|
|
81
|
+
✨ No reducers. No boilerplate.
|
|
82
|
+
|
|
48
83
|
---
|
|
49
84
|
|
|
50
85
|
## 🔹 Core Usage
|
|
@@ -246,16 +281,11 @@ function StoreView({ store }: { store: Store<any> }) {
|
|
|
246
281
|
|
|
247
282
|
```tsx
|
|
248
283
|
// Only re-renders when saving changes, not the whole store.
|
|
249
|
-
import { useStoreSelector } from
|
|
284
|
+
import { useStoreSelector } from "chrono-state-z"
|
|
250
285
|
|
|
251
286
|
function SavingBadge({ store }) {
|
|
252
287
|
const saving = useStoreSelector(store, s => s.saving)
|
|
253
|
-
|
|
254
|
-
// store,
|
|
255
|
-
// s => s.meta,
|
|
256
|
-
// shallowEqual
|
|
257
|
-
// )
|
|
258
|
-
return saving ? 'Saving...' : 'Idle'
|
|
288
|
+
return saving ? "Saving..." : "Idle"
|
|
259
289
|
}
|
|
260
290
|
|
|
261
291
|
```
|
|
@@ -269,6 +299,8 @@ function SavingBadge({ store }) {
|
|
|
269
299
|
```ts
|
|
270
300
|
import { useWatch } from 'chrono-state-z'
|
|
271
301
|
|
|
302
|
+
const user = atom<{ role?: string } | null>(null)
|
|
303
|
+
|
|
272
304
|
function AuthGuard() {
|
|
273
305
|
useWatch(
|
|
274
306
|
() => user(),
|
|
@@ -317,7 +349,7 @@ export function createUserLogic() {
|
|
|
317
349
|
```tsx
|
|
318
350
|
function UserView({ logic }) {
|
|
319
351
|
const user = useAtom(logic.user)
|
|
320
|
-
const name = useComputed(
|
|
352
|
+
const name = useComputed(logic.name)
|
|
321
353
|
|
|
322
354
|
return (
|
|
323
355
|
<>
|
|
@@ -331,16 +363,74 @@ function UserView({ logic }) {
|
|
|
331
363
|
|
|
332
364
|
---
|
|
333
365
|
|
|
334
|
-
##
|
|
366
|
+
## 🔍 Comparison
|
|
367
|
+
|
|
368
|
+
<b>This is not about “better” — it's about architectural.</b>
|
|
369
|
+
|
|
370
|
+
| Feature | chrono-state-z | Redux Toolkit | Zustand | Jotai | MobX |
|
|
371
|
+
| --------------------------- | -------------- | ------------- | -------- | ----- | ---- |
|
|
372
|
+
| Fine-grained reactivity | ✅ | ❌ | ⚠️ | ✅ | ✅ |
|
|
373
|
+
| Built-in async primitives | ✅ | ⚠️ | ❌ | ⚠️ | ❌ |
|
|
374
|
+
| Scheduler / priority system | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
375
|
+
| Headless (non-React) core | ✅ | ✅ | ⚠️ | ⚠️ | ✅ |
|
|
376
|
+
| Boilerplate level | ✅ | ❌ | ✅ | ✅ | ⚠️ |
|
|
377
|
+
| Devtools maturity | ⚠️ | ✅ | ✅ | ⚠️ | ✅ |
|
|
378
|
+
| Learning curve | ⚠️ | ⚠️ | ✅ | ✅ | ⚠️ |
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
<br />
|
|
382
|
+
|
|
383
|
+
<b>📝 Notes</b>
|
|
384
|
+
|
|
385
|
+
⚠️ Fine-grained in Zustand: achieved via selectors, but not dependency-tracked graph-level.
|
|
386
|
+
|
|
387
|
+
⚠️ Async in Redux / Jotai / Recoil: supported via patterns (thunks, query libs, async selectors), not core-first primitives.
|
|
388
|
+
|
|
389
|
+
⚠️ Headless in Zustand/Jotai: possible, but primarily designed for React usage.
|
|
390
|
+
|
|
391
|
+
⚠️ Devtools: Redux and MobX have mature ecosystems; newer libs are still evolving.
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
## ⚖️ Strengths Compared to Others
|
|
396
|
+
|
|
397
|
+
<b>vs Redux Toolkit</b>
|
|
398
|
+
|
|
399
|
+
- More fine-grained updates
|
|
400
|
+
- Less reducer boilerplate
|
|
401
|
+
- Built-in reactive primitives
|
|
402
|
+
- Redux has stronger ecosystem & devtools
|
|
403
|
+
|
|
404
|
+
<b>vs Zustand</b>
|
|
405
|
+
|
|
406
|
+
- More structured async handling
|
|
407
|
+
- Explicit intent layer
|
|
408
|
+
- Built-in scheduler support
|
|
409
|
+
- Zustand is simpler & lighter for small apps
|
|
410
|
+
|
|
411
|
+
<b>vs Jotai</b>
|
|
412
|
+
|
|
413
|
+
- More explicit effect + scheduler control
|
|
414
|
+
- Async-first primitives
|
|
415
|
+
- Jotai is more minimal and React-native
|
|
416
|
+
|
|
417
|
+
<b>vs MobX</b>
|
|
418
|
+
|
|
419
|
+
- More explicit dependency graph (no proxy magic)
|
|
420
|
+
- Better control over update priority
|
|
421
|
+
- MobX is more ergonomic for mutable patterns
|
|
422
|
+
|
|
423
|
+
<b>vs Recoil</b>
|
|
424
|
+
|
|
425
|
+
- Headless core (not React-bound)
|
|
426
|
+
- Explicit effect system
|
|
427
|
+
- Recoil has better React DevTools integration
|
|
428
|
+
|
|
429
|
+
<b>vs Solid signals</b>
|
|
335
430
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
| Async primitives | ✅ | ⚠️ | ❌ | ⚠️ |
|
|
340
|
-
| Intent / effect layer | ✅ | ⚠️ | ❌ | ❌ |
|
|
341
|
-
| Scheduler / priority | ✅ | ❌ | ❌ | ❌ |
|
|
342
|
-
| Headless (non-React) core | ✅ | ❌ | ⚠️ | ❌ |
|
|
343
|
-
| Testability | ✅ | ⚠️ | ⚠️ | ❌ |
|
|
431
|
+
- Similar fine-grained reactive model
|
|
432
|
+
- Designed for React ecosystem
|
|
433
|
+
- Solid is framework-native and extremely optimized
|
|
344
434
|
|
|
345
435
|
---
|
|
346
436
|
|
package/build/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var e=require("react"),t=require("intentx-state-z");function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var n=r(e);function c(e){return n.useSyncExternalStore(r=>t.effect(()=>{e(),r()}),e,e)}Object.defineProperty(exports,"asyncAtom",{enumerable:!0,get:function(){return t.asyncAtom}}),Object.defineProperty(exports,"asyncAtomFamily",{enumerable:!0,get:function(){return t.asyncAtomFamily}}),Object.defineProperty(exports,"asyncComputed",{enumerable:!0,get:function(){return t.asyncComputed}}),Object.defineProperty(exports,"atom",{enumerable:!0,get:function(){return t.atom}}),Object.defineProperty(exports,"atomMiddleware",{enumerable:!0,get:function(){return t.atomMiddleware}}),Object.defineProperty(exports,"batch",{enumerable:!0,get:function(){return t.batch}}),Object.defineProperty(exports,"computed",{enumerable:!0,get:function(){return t.computed}}),Object.defineProperty(exports,"createAppScope",{enumerable:!0,get:function(){return t.createAppScope}}),Object.defineProperty(exports,"createSelector",{enumerable:!0,get:function(){return t.createSelector}}),Object.defineProperty(exports,"createSharedIntentBus",{enumerable:!0,get:function(){return t.createSharedIntentBus}}),Object.defineProperty(exports,"createStore",{enumerable:!0,get:function(){return t.createStore}}),Object.defineProperty(exports,"effect",{enumerable:!0,get:function(){return t.effect}}),Object.defineProperty(exports,"factoryAtom",{enumerable:!0,get:function(){return t.factoryAtom}}),Object.defineProperty(exports,"readonlyAtom",{enumerable:!0,get:function(){return t.readonlyAtom}}),Object.defineProperty(exports,"selectAtom",{enumerable:!0,get:function(){return t.selectAtom}}),Object.defineProperty(exports,"transaction",{enumerable:!0,get:function(){return t.transaction}}),Object.defineProperty(exports,"watch",{enumerable:!0,get:function(){return t.watch}}),Object.defineProperty(exports,"watchSelector",{enumerable:!0,get:function(){return t.watchSelector}}),exports.scheduleReactJob=function(t,r="normal"){"low"===r?e.startTransition(t):t()},exports.useAtom=c,exports.useAtomSelector=function(r,n,c=Object.is){const o=e.useRef(t.createSelector(n,c)),u=()=>o.current(r());return e.useSyncExternalStore(e=>t.effect(()=>{r(),e()}),u,u)},exports.useBatch=function(){return t.batch},exports.useComputed=function(e,r=[]){return c(n.useMemo(()=>t.computed(e),r))},exports.useEffectReact=function(e,r="normal"){const c=n.useRef(e);c.current=e,n.useEffect(()=>{const e=t.effect(()=>{c.current()},r);return()=>e()},[r])},exports.useFactoryAtom=function(e,t){const r=n.useRef(e);r.current=e;const o=n.useRef(null),u=n.useRef(null);return null!==o.current&&u.current===t||(o.current=r.current(t),u.current=t),c(o.current)},exports.useStore=function(t){return e.useSyncExternalStore(t.subscribe,t.state,t.state)},exports.useStoreSelector=function(e,r,c=Object.is){const o=n.useRef(r);o.current=r;const u=n.useRef(t.createSelector(e=>o.current(e),c)),s=n.useCallback(()=>u.current(e.state()),[e]);return n.useSyncExternalStore(e.subscribe,s,s)},exports.useWatch=function(e,r,c){const o=n.useRef(r);o.current=r;const u=n.useRef(c);u.current=c,n.useEffect(()=>{const r=t.watch(e,e=>{o.current(e)},u.current);return()=>null==r?void 0:r()},[e])};
|
package/build/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export * from "./react";
|
|
2
|
+
export { atom, readonlyAtom, atomMiddleware, } from "intentx-state-z";
|
|
3
|
+
export { asyncAtom, asyncAtomFamily, } from "intentx-state-z";
|
|
4
|
+
export { asyncComputed } from "intentx-state-z";
|
|
5
|
+
export { computed, effect, batch, transaction, } from "intentx-state-z";
|
|
6
|
+
export { createStore, createAppScope, createSharedIntentBus } from "intentx-state-z";
|
|
7
|
+
export type { Atom, Priority, Store, Subscriber } from "intentx-state-z";
|
|
8
|
+
export { createSelector, selectAtom, watchSelector, watch } from "intentx-state-z";
|
|
9
|
+
export { factoryAtom } from "intentx-state-z";
|
package/build/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import*as t from"react";import e,{startTransition as r}from"react";import{effect as n,createSelector as c,batch as u,computed as o,watch as s}from"intentx-state-z";export{asyncAtom,asyncAtomFamily,asyncComputed,atom,atomMiddleware,batch,computed,createAppScope,createSelector,createSharedIntentBus,createStore,effect,factoryAtom,readonlyAtom,selectAtom,transaction,watch,watchSelector}from"intentx-state-z";function a(e){return t.useSyncExternalStore(t=>n(()=>{e(),t()}),e,e)}function f(t,r,u=Object.is){const o=e.useRef(c(r,u)),s=()=>o.current(t());return e.useSyncExternalStore(e=>n(()=>{t(),e()}),s,s)}function i(){return u}function l(e,r=[]){return a(t.useMemo(()=>o(e),r))}function m(e,r="normal"){const c=t.useRef(e);c.current=e,t.useEffect(()=>{const t=n(()=>{c.current()},r);return()=>t()},[r])}function S(e,r){const n=t.useRef(e);n.current=e;const c=t.useRef(null),u=t.useRef(null);return null!==c.current&&u.current===r||(c.current=n.current(r),u.current=r),a(c.current)}function p(t){return e.useSyncExternalStore(t.subscribe,t.state,t.state)}function y(e,r,n=Object.is){const u=t.useRef(r);u.current=r;const o=t.useRef(c(t=>u.current(t),n)),s=t.useCallback(()=>o.current(e.state()),[e]);return t.useSyncExternalStore(e.subscribe,s,s)}function R(e,r,n){const c=t.useRef(r);c.current=r;const u=t.useRef(n);u.current=n,t.useEffect(()=>{const t=s(e,t=>{c.current(t)},u.current);return()=>null==t?void 0:t()},[e])}function b(t,e="normal"){"low"===e?r(t):t()}export{b as scheduleReactJob,a as useAtom,f as useAtomSelector,i as useBatch,l as useComputed,m as useEffectReact,S as useFactoryAtom,p as useStore,y as useStoreSelector,R as useWatch};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Priority } from 'intentx-
|
|
1
|
+
import type { Priority } from 'intentx-state-z';
|
|
2
2
|
export declare function scheduleReactJob(job: () => void, priority?: Priority): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { batch } from 'intentx-
|
|
1
|
+
import { batch } from 'intentx-state-z';
|
|
2
2
|
export declare function useBatch(): typeof batch;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export declare function useComputed<T>(fn: () => T, deps?: React.DependencyList): T;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Priority } from 'intentx-
|
|
1
|
+
import { Priority } from 'intentx-state-z';
|
|
2
2
|
export declare function useEffectReact(fn: () => void, priority?: Priority): void;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { WatchOptions } from "intentx-state-z";
|
|
2
|
+
export declare function useWatch<T>(getter: () => T, fn: (val: T) => void, options?: WatchOptions<T>): void;
|
package/package.json
CHANGED
|
@@ -1,77 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chrono-state-z",
|
|
3
|
-
"version": "2.1
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.2.1-iz",
|
|
4
|
+
"description": "A fine-grained, intent-driven reactive state runtime for building complex React logic outside components.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Delpi.Kye",
|
|
7
7
|
"sideEffects": false,
|
|
8
|
-
|
|
9
8
|
"main": "build/index.cjs.js",
|
|
10
9
|
"module": "build/index.esm.js",
|
|
11
10
|
"types": "build/index.d.ts",
|
|
12
|
-
|
|
13
11
|
"exports": {
|
|
14
12
|
".": {
|
|
15
13
|
"types": "./build/index.d.ts",
|
|
16
14
|
"import": "./build/index.esm.js",
|
|
17
15
|
"require": "./build/index.cjs.js"
|
|
18
|
-
},
|
|
19
|
-
"./react": {
|
|
20
|
-
"types": "./build/react/index.d.ts",
|
|
21
|
-
"import": "./build/react/index.esm.js",
|
|
22
|
-
"require": "./build/react/index.cjs.js"
|
|
23
|
-
},
|
|
24
|
-
"./devtools": {
|
|
25
|
-
"types": "./build/devtools/index.d.ts",
|
|
26
|
-
"import": "./build/devtools/index.esm.js",
|
|
27
|
-
"require": "./build/devtools/index.cjs.js"
|
|
28
16
|
}
|
|
29
17
|
},
|
|
30
|
-
|
|
31
18
|
"files": [
|
|
32
19
|
"build"
|
|
33
20
|
],
|
|
34
|
-
|
|
35
21
|
"scripts": {
|
|
36
22
|
"clean": "rimraf build",
|
|
37
23
|
"build": "rollup -c",
|
|
38
24
|
"cb": "npm run clean && npm run build",
|
|
39
25
|
"prepublishOnly": "npm run cb"
|
|
40
26
|
},
|
|
41
|
-
|
|
42
27
|
"repository": {
|
|
43
28
|
"type": "git",
|
|
44
29
|
"url": "https://github.com/delpikye-v/chrono-state.git"
|
|
45
30
|
},
|
|
46
|
-
|
|
47
31
|
"homepage": "https://github.com/delpikye-v/chrono-state",
|
|
48
|
-
|
|
49
32
|
"bugs": {
|
|
50
33
|
"url": "https://github.com/delpikye-v/chrono-state/issues"
|
|
51
34
|
},
|
|
52
|
-
|
|
53
35
|
"keywords": [
|
|
54
36
|
"state-management",
|
|
37
|
+
"react-state",
|
|
55
38
|
"reactive",
|
|
39
|
+
"fine-grained",
|
|
40
|
+
"signals",
|
|
56
41
|
"atom",
|
|
57
42
|
"computed",
|
|
58
43
|
"async-state",
|
|
44
|
+
"scheduler",
|
|
45
|
+
"deterministic",
|
|
59
46
|
"intent",
|
|
60
|
-
"intent-first",
|
|
61
47
|
"logic-first",
|
|
62
|
-
"effects",
|
|
63
|
-
"scheduler",
|
|
64
48
|
"headless",
|
|
65
|
-
"react",
|
|
66
49
|
"react-hooks",
|
|
67
50
|
"react-18"
|
|
68
51
|
],
|
|
69
|
-
|
|
70
52
|
"peerDependencies": {
|
|
71
|
-
"react": "
|
|
72
|
-
|
|
53
|
+
"react": ">=18"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"intentx-state-z": "^0.1.1"
|
|
73
57
|
},
|
|
74
|
-
|
|
75
58
|
"devDependencies": {
|
|
76
59
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
77
60
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Priority } from "intentx-core-z";
|
|
2
|
-
export type AsyncAtom<T> = {
|
|
3
|
-
(): T;
|
|
4
|
-
set(v: T, p?: Priority): void;
|
|
5
|
-
load(): Promise<T>;
|
|
6
|
-
cancel(): void;
|
|
7
|
-
invalidate(p?: Priority): void;
|
|
8
|
-
};
|
|
9
|
-
export declare function asyncAtom<T>(fetcher: (signal?: AbortSignal) => Promise<T>): AsyncAtom<T>;
|
package/build/core/atom.d.ts
DELETED
package/build/core/computed.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function computed<T>(getter: () => T): () => T;
|
package/build/core/effect.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function factoryAtom<K, A>(factory: (key: K) => A): (key: K) => A;
|
package/build/core/graph.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export type NodeType = 'atom' | 'computed' | 'effect';
|
|
2
|
-
export type GraphNode = {
|
|
3
|
-
id: number;
|
|
4
|
-
name?: string;
|
|
5
|
-
type: NodeType;
|
|
6
|
-
value?: any;
|
|
7
|
-
deps: Set<number>;
|
|
8
|
-
highlighted?: boolean;
|
|
9
|
-
};
|
|
10
|
-
export type GraphSnapshotNode = {
|
|
11
|
-
id: number;
|
|
12
|
-
name?: string;
|
|
13
|
-
type: NodeType;
|
|
14
|
-
value?: any;
|
|
15
|
-
deps: number[];
|
|
16
|
-
highlighted?: boolean;
|
|
17
|
-
};
|
|
18
|
-
export declare function trackNode(type: NodeType, name?: string, value?: any): GraphNode;
|
|
19
|
-
export declare function linkNodes(from: GraphNode, to: GraphNode): void;
|
|
20
|
-
export declare function getGraphSnapshot(): GraphSnapshotNode[];
|
|
21
|
-
export declare function highlightNode(id: number): void;
|
|
22
|
-
export declare function clearHighlights(): void;
|
package/build/core/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { atom } from "./atom";
|
|
2
|
-
export { computed } from "./computed";
|
|
3
|
-
export { asyncAtom } from "./asyncAtom";
|
|
4
|
-
export { asyncComputed } from "./asyncComputed";
|
|
5
|
-
export { effect } from "./effect";
|
|
6
|
-
export { watch } from "./watch";
|
|
7
|
-
export { createStore } from "./createStore";
|
|
8
|
-
export { selectAtom, createSelector } from "./selector";
|
|
9
|
-
export type { Store, Subscriber } from "./store";
|
|
10
|
-
export { factoryAtom } from "./factoryAtom";
|
package/build/core/selector.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type EqualityFn<T> = (a: T, b: T) => boolean;
|
|
2
|
-
export declare function createSelector<S, R>(select: (state: S) => R, isEqual?: EqualityFn<R>): (state: S) => R;
|
|
3
|
-
export declare function selectAtom<T, R>(atom: () => T, selector: (value: T) => R, onChange: (value: R) => void, options?: {
|
|
4
|
-
isEqual?: (a: R, b: R) => boolean;
|
|
5
|
-
immediate?: boolean;
|
|
6
|
-
}): () => void;
|
|
7
|
-
export declare function watchSelector<S, R>(getState: () => S, subscribe: (fn: () => void) => () => void, selector: (state: S) => R, onChange: (value: R) => void, isEqual?: EqualityFn<R>): () => void;
|
package/build/core/store.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { IntentHandler, Scope } from "intentx-core-z";
|
|
2
|
-
import { EqualityFn } from "./selector";
|
|
3
|
-
export type Subscriber = () => void;
|
|
4
|
-
export type Store<S extends object> = {
|
|
5
|
-
scope: Scope;
|
|
6
|
-
state(): S;
|
|
7
|
-
setState(fn: (s: S) => void): void;
|
|
8
|
-
subscribe(fn: Subscriber): () => void;
|
|
9
|
-
emit(type: string, payload?: any): Promise<void>;
|
|
10
|
-
on(type: string, handler: IntentHandler<S>): () => void;
|
|
11
|
-
watch<R>(selector: (state: S) => R, onChange: (value: R) => void, isEqual?: EqualityFn<R>): () => void;
|
|
12
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { batch as transaction } from "intentx-core-z";
|
package/build/core/watch.d.ts
DELETED