jotai-state-tree 1.7.5 → 1.9.0
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 +20 -0
- package/dist/{chunk-I2ZPT6O4.mjs → chunk-37XARU7S.mjs} +725 -9
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +726 -8
- package/dist/index.mjs +5 -1
- package/dist/{router-DwXAzNVB.d.mts → persistence-BLu5h3-2.d.mts} +90 -1
- package/dist/{router-DwXAzNVB.d.ts → persistence-BLu5h3-2.d.ts} +90 -1
- package/dist/react.d.mts +18 -3
- package/dist/react.d.ts +18 -3
- package/dist/react.js +762 -26
- package/dist/react.mjs +21 -1
- package/package.json +2 -1
- package/src/__tests__/examples/offline-sync-persistence.test.tsx +261 -0
- package/src/__tests__/performance.test.ts +15 -15
- package/src/__tests__/persistence.test.ts +624 -0
- package/src/__tests__/utilities_extra.test.ts +89 -6
- package/src/index.ts +17 -0
- package/src/persistence.ts +923 -0
- package/src/react.ts +51 -0
- package/src/router.ts +43 -7
package/README.md
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
A MobX-State-Tree (MST) compatible state management library powered by [Jotai](https://jotai.org/).
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/jotai-state-tree)
|
|
6
|
+
[](https://github.com/bmartel/jotai-state-tree/actions/workflows/release.yml)
|
|
7
|
+
[](https://github.com/bmartel/jotai-state-tree/actions/workflows/release.yml)
|
|
6
8
|
[](LICENSE)
|
|
7
9
|
|
|
8
10
|
`jotai-state-tree` combines the transactional, tree-structured state model of MobX-State-Tree with the lightweight, zero-leak, high-performance atomic updates of Jotai. It is designed to be an API-compatible, drop-in replacement for MobX-State-Tree, featuring perfect TypeScript type safety out of the box.
|
|
@@ -32,6 +34,24 @@ npm install jotai-state-tree jotai
|
|
|
32
34
|
|
|
33
35
|
---
|
|
34
36
|
|
|
37
|
+
## React Native Compatibility
|
|
38
|
+
|
|
39
|
+
`jotai-state-tree` is fully compatible with React Native projects.
|
|
40
|
+
|
|
41
|
+
### Prerequisites & JS Engine
|
|
42
|
+
- **React Native Version**: `>= 0.70` is required.
|
|
43
|
+
- **JavaScript Engine**: The library relies on native ES2021 `WeakRef` and `FinalizationRegistry` features for memory management. If you use the Hermes engine (default since React Native 0.70), it must be version `0.12.0` or newer.
|
|
44
|
+
|
|
45
|
+
### Using the Router in React Native
|
|
46
|
+
When running in React Native (or any non-browser environment), the built-in state router automatically disables DOM/browser integration and behaves as a fully-featured **in-memory router**. It maintains a navigation history stack internally, enabling you to use:
|
|
47
|
+
- `push(path)` / `replace(path)`
|
|
48
|
+
- `go(delta)` / `goBack()` / `goForward()`
|
|
49
|
+
- `RouteView` to reactively render screen components based on the active path
|
|
50
|
+
|
|
51
|
+
This allows you to manage native navigation state trees with full time-travel, middleware, and action recording support!
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
35
55
|
## Quick Start
|
|
36
56
|
|
|
37
57
|
```typescript
|