@asaidimu/react-store 5.1.1 → 5.2.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 +36 -19
- package/index.cjs +1 -1
- package/index.d.cts +4 -4
- package/index.d.ts +4 -4
- package/index.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @asaidimu/react-store
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/@asaidimu/react-store)
|
|
3
|
+
[](https://www.npmjs.com/package/@asaidimu/react-store)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
[](https://github.com/asaidimu/node-react/actions)
|
|
6
6
|
[](https://www.typescriptlang.org/)
|
|
@@ -50,16 +50,16 @@ Designed with modern React in mind, it leverages `useSyncExternalStore` for opti
|
|
|
50
50
|
|
|
51
51
|
### Key Features
|
|
52
52
|
|
|
53
|
-
* 📊 **Reactive State Management**: Automatically tracks dependencies to optimize component renders and ensure efficient updates using `useSyncExternalStore
|
|
54
|
-
* 🛡️ **Type-Safe**: Developed entirely in TypeScript, providing strict type checking for state, actions, artifacts, and middleware.
|
|
55
|
-
* ⚙️ **Middleware Pipeline**: Implement custom logic to `transform` or `validate` state changes before they are applied.
|
|
56
|
-
* 💾 **Built-in Persistence**: Seamlessly integrate with web storage mechanisms like `IndexedDB` and `WebStorage` (localStorage/sessionStorage)
|
|
53
|
+
* 📊 **Reactive State Management**: Automatically tracks dependencies to optimize component renders and ensure efficient updates using React's `useSyncExternalStore` hook.
|
|
54
|
+
* 🛡️ **Type-Safe**: Developed entirely in TypeScript, providing strict type checking for state, actions, artifacts, and middleware, minimizing runtime errors.
|
|
55
|
+
* ⚙️ **Middleware Pipeline**: Implement custom logic to `transform` or `validate` state changes before they are applied, with full access to the `ActionContext` including current state and artifact resolution.
|
|
56
|
+
* 💾 **Built-in Persistence**: Seamlessly integrate with web storage mechanisms like `IndexedDB` and `WebStorage` (localStorage/sessionStorage) via `@asaidimu/utils-persistence`, including cross-tab synchronization.
|
|
57
57
|
* 🔍 **Deep Observability**: Gain profound insights into your application's state with built-in metrics, detailed event logging, state history, and time-travel debugging capabilities via the `StoreObserver` instance.
|
|
58
|
-
* 🚀 **Artifact Management**: Define and reactively resolve asynchronous resources, services, or derived data
|
|
59
|
-
* ⚡ **Performance Optimized**: Features intelligent selector caching and debounced actions with configurable immediate execution to prevent rapid successive calls and ensure smooth application performance.
|
|
60
|
-
* ⏱️ **Action Loading States**: Track the real-time loading status of individual actions, providing immediate feedback on asynchronous operations.
|
|
58
|
+
* 🚀 **Artifact Management**: Define and reactively resolve asynchronous resources, services, or derived data using `@asaidimu/utils-artifacts`, enabling advanced dependency injection patterns and lazy loading of complex logic.
|
|
59
|
+
* ⚡ **Performance Optimized**: Features intelligent selector caching and debounced actions with configurable immediate execution (`debounceTime: 0`) to prevent rapid successive calls and ensure smooth application performance.
|
|
60
|
+
* ⏱️ **Action Loading States**: Track the real-time loading status of individual actions via the `watch` function, providing immediate feedback on asynchronous operations in the UI.
|
|
61
61
|
* ⚛️ **React 19+ Ready**: Fully compatible with the latest React versions, leveraging modern APIs for enhanced performance and development ergonomics.
|
|
62
|
-
* 🗑️ **Explicit Deletions**: Use `Symbol.for("delete")` to explicitly remove properties from nested state objects.
|
|
62
|
+
* 🗑️ **Explicit Deletions**: Use `Symbol.for("delete")` to explicitly remove properties from nested state objects, providing a clear and type-safe way to manage deletions.
|
|
63
63
|
|
|
64
64
|
## Installation & Setup
|
|
65
65
|
|
|
@@ -297,6 +297,18 @@ import { useEffect, useMemo } from 'react';
|
|
|
297
297
|
import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts';
|
|
298
298
|
import { useStore, Product, CartItem, Order, ECommerceState } from './store';
|
|
299
299
|
|
|
300
|
+
// Assuming Card, CardHeader, CardTitle, CardContent, CardFooter, Button are defined elsewhere
|
|
301
|
+
const Card = ({ children }: { children: React.ReactNode }) => <div className="bg-white rounded-lg shadow-md p-4 flex flex-col">{children}</div>;
|
|
302
|
+
const CardHeader = ({ children }: { children: React.ReactNode }) => <div className="mb-2">{children}</div>;
|
|
303
|
+
const CardTitle = ({ children }: { children: React.ReactNode }) => <h3 className="text-lg font-bold">{children}</h3>;
|
|
304
|
+
const CardContent = ({ children, className }: { children: React.ReactNode, className?: string }) => <div className={`flex-grow ${className || ''}`}>{children}</div>;
|
|
305
|
+
const CardFooter = ({ children }: { children: React.ReactNode }) => <div className="mt-4">{children}</div>;
|
|
306
|
+
const Button = ({ children, onClick, className, disabled }: { children: React.ReactNode, onClick: () => void, className?: string, disabled?: boolean }) => (
|
|
307
|
+
<button onClick={onClick} className={`bg-blue-500 text-white px-4 py-2 rounded-md hover:bg-blue-600 ${className || ''}`} disabled={disabled}>
|
|
308
|
+
{children}
|
|
309
|
+
</button>
|
|
310
|
+
);
|
|
311
|
+
|
|
300
312
|
|
|
301
313
|
const ProductCatalog = () => {
|
|
302
314
|
const { select, actions, resolve } = useStore();
|
|
@@ -365,13 +377,10 @@ function App() {
|
|
|
365
377
|
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
|
366
378
|
<div className="lg:col-span-2 space-y-6">
|
|
367
379
|
<ProductCatalog />
|
|
368
|
-
{/*
|
|
380
|
+
{/* Placeholder for other components */}
|
|
369
381
|
</div>
|
|
370
382
|
<div className="space-y-6">
|
|
371
|
-
{/*
|
|
372
|
-
{/* <UserAnalytics /> */}
|
|
373
|
-
{/* <TopSellingProducts /> */}
|
|
374
|
-
{/* <RecentOrdersFeed /> */}
|
|
383
|
+
{/* Placeholder for other components */}
|
|
375
384
|
</div>
|
|
376
385
|
</div>
|
|
377
386
|
</main>
|
|
@@ -439,7 +448,8 @@ async function runDeleteExample() {
|
|
|
439
448
|
// After clearing all except ID: { id: 'product-123' }
|
|
440
449
|
}
|
|
441
450
|
|
|
442
|
-
runDeleteExample()
|
|
451
|
+
// In a real application, you would call runDeleteExample() in a component's useEffect or similar.
|
|
452
|
+
// runDeleteExample();
|
|
443
453
|
```
|
|
444
454
|
|
|
445
455
|
### Persistence
|
|
@@ -538,6 +548,7 @@ function AppWithPersistence() {
|
|
|
538
548
|
</div>
|
|
539
549
|
);
|
|
540
550
|
}
|
|
551
|
+
// Render AppWithPersistence in your React app.
|
|
541
552
|
```
|
|
542
553
|
|
|
543
554
|
### Middleware (Transform & Validate)
|
|
@@ -626,6 +637,7 @@ function CartComponent() {
|
|
|
626
637
|
</div>
|
|
627
638
|
);
|
|
628
639
|
}
|
|
640
|
+
// Render CartComponent in your React app.
|
|
629
641
|
```
|
|
630
642
|
|
|
631
643
|
### Artifact Management
|
|
@@ -744,6 +756,7 @@ function ArtifactConsumer() {
|
|
|
744
756
|
</div>
|
|
745
757
|
);
|
|
746
758
|
}
|
|
759
|
+
// Render ArtifactConsumer in your React app.
|
|
747
760
|
```
|
|
748
761
|
|
|
749
762
|
### Observability
|
|
@@ -829,6 +842,7 @@ function DebugPanel() {
|
|
|
829
842
|
</div>
|
|
830
843
|
);
|
|
831
844
|
}
|
|
845
|
+
// Render DebugPanel in your React app.
|
|
832
846
|
```
|
|
833
847
|
|
|
834
848
|
### Remote Observability
|
|
@@ -1002,6 +1016,7 @@ function EventMonitor() {
|
|
|
1002
1016
|
</div>
|
|
1003
1017
|
);
|
|
1004
1018
|
}
|
|
1019
|
+
// Render EventMonitor in your React app.
|
|
1005
1020
|
```
|
|
1006
1021
|
|
|
1007
1022
|
### Watching Action Loading States
|
|
@@ -1059,6 +1074,7 @@ function DataLoader() {
|
|
|
1059
1074
|
</div>
|
|
1060
1075
|
);
|
|
1061
1076
|
}
|
|
1077
|
+
// Render DataLoader in your React app.
|
|
1062
1078
|
```
|
|
1063
1079
|
|
|
1064
1080
|
### Advanced Hook Properties
|
|
@@ -1147,9 +1163,9 @@ This library leverages the following `@asaidimu` packages for its core functiona
|
|
|
1147
1163
|
### Data Flow
|
|
1148
1164
|
|
|
1149
1165
|
1. **Action Dispatch**: A React component calls a bound action (e.g., `actions.addItem()`).
|
|
1150
|
-
2. **Action Debouncing**: Actions are debounced by default (configurable), preventing rapid successive calls.
|
|
1166
|
+
2. **Action Debouncing**: Actions are debounced by default (configurable via `debounceTime` in `StoreOptions`), preventing rapid successive calls.
|
|
1151
1167
|
3. **Action Loading State Update**: The store immediately updates the loading state for the dispatched action to `true` via an internal `ReactiveDataStore`.
|
|
1152
|
-
4. **Action Execution Tracking**: The `ActionTracker` records the action's details (name, parameters, start time).
|
|
1168
|
+
4. **Action Execution Tracking**: The `ActionTracker` records the action's details (name, parameters, start time) if `enableMetrics` is true.
|
|
1153
1169
|
5. **State Update Request**: The action's implementation (receiving `ActionContext` with `state` and `resolve`) returns a partial state update or a promise resolving to one.
|
|
1154
1170
|
6. **Transaction Context**: If the action is wrapped within `store.transaction()`, the current state is snapshotted to enable potential rollback.
|
|
1155
1171
|
7. **Validator Middleware**: The update first passes through any registered `validate` middleware. If any validator returns `false` or throws an error, the update is halted, and the state remains unchanged (and rolled back if in a transaction).
|
|
@@ -1189,8 +1205,9 @@ We welcome contributions! Please follow the guidelines below.
|
|
|
1189
1205
|
### Scripts
|
|
1190
1206
|
|
|
1191
1207
|
* `bun ci`: Installs dependencies, typically used in CI/CD environments to ensure a clean install.
|
|
1192
|
-
* `bun test`: Runs all unit tests using `Vitest` in interactive watch mode.
|
|
1193
1208
|
* `bun test:ci`: Runs all unit tests once, suitable for CI/CD pipelines.
|
|
1209
|
+
* `bun test:watch`: Runs all unit tests using `Vitest` in interactive watch mode.
|
|
1210
|
+
* `bun test`: Runs all unit tests once using `Vitest`.
|
|
1194
1211
|
* `bun clean`: Removes the `dist` directory, cleaning up previous build artifacts.
|
|
1195
1212
|
* `bun prebuild`: Pre-build step that cleans the `dist` directory and runs an internal package synchronization script (`.sync-package.ts`).
|
|
1196
1213
|
* `bun build`: Compiles the TypeScript source into `dist/` for CJS and ESM formats, generates type definitions, and minifies the code using `Terser`.
|
|
@@ -1206,7 +1223,7 @@ To run tests:
|
|
|
1206
1223
|
```bash
|
|
1207
1224
|
bun test
|
|
1208
1225
|
# or to run in watch mode
|
|
1209
|
-
bun test
|
|
1226
|
+
bun test:watch
|
|
1210
1227
|
```
|
|
1211
1228
|
|
|
1212
1229
|
### Contributing Guidelines
|
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("react"),t=require("@asaidimu/utils-store"),r=require("@asaidimu/utils-artifacts"),s=class{executions=[];maxHistory=100;listeners=new Set;track(e){this.executions.unshift(e),this.executions.length>this.maxHistory&&this.executions.pop(),this.notify()}getExecutions(){return[...this.executions]}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){this.listeners.forEach(e=>e())}};exports.createStore=function(a,{enableMetrics:
|
|
1
|
+
"use strict";var e=require("react"),t=require("@asaidimu/utils-store"),r=require("@asaidimu/utils-artifacts"),s=class{executions=[];maxHistory=100;listeners=new Set;track(e){this.executions.unshift(e),this.executions.length>this.maxHistory&&this.executions.pop(),this.notify()}getExecutions(){return[...this.executions]}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){this.listeners.forEach(e=>e())}};exports.createStore=function(a,n){const{enableMetrics:i,...c}=n||{},o=new t.ReactiveDataStore(a.state,c.persistence),u=Object.keys(a.actions).reduce((e,t)=>(e[t]=!1,e),{}),l=new t.ReactiveDataStore(u),d=i?new t.StoreObserver(o,c):void 0,m=i?new s:void 0;o.on("action:start",({name:e})=>{l.set(()=>({[e]:!0}))}),o.on("action:complete",e=>{l.set(()=>({[e.name]:!1})),i&&m&&m.track({id:e.actionId,name:e.name,params:e.params,startTime:e.startTime,endTime:e.endTime,duration:e.duration,status:"success",result:e.result})}),o.on("action:error",e=>{l.set(()=>({[e.name]:!1})),i&&m&&m.track({id:e.actionId,name:e.name,params:e.params,startTime:e.startTime,endTime:e.endTime,duration:e.duration,status:"error",error:e.error})});const h=e=>(o.isReady()&&e(),o.on("persistence:ready",e)),y=()=>o.isReady(),b=new r.ArtifactContainer(o),f=b.resolve.bind(b);a.artifacts&&Object.entries(a.artifacts).forEach(([e,t])=>{b.register({key:e,factory:t.factory,scope:t.scope,lazy:t.lazy})}),a.transform&&Object.entries(a.transform).forEach(([e,t])=>{o.use({name:e,action:(e,r)=>t({state:e,resolve:f},r)})}),a.validate&&Object.entries(a.validate).forEach(([e,t])=>{o.use({block:!0,name:e,action:(e,r)=>t({state:e,resolve:f},r)})});const S=Object.entries(a.actions).reduce((e,[t,r])=>(o.register({name:t,fn:(e,...t)=>r({state:e,resolve:f},...t)}),e[t]=(...e)=>o.dispatch(t,...e),e),{});return function(t){t&&o.set(t);const r=()=>e.useSyncExternalStore(e=>o.watch("",e),()=>o.get(),()=>o.get()),s=e.useSyncExternalStore(h,y,y);return{select:t=>{const r=o.select(t);return e.useSyncExternalStore(e=>r.subscribe(e),()=>r.get(),()=>r.get())},watch:t=>{const r=l.select(e=>e[t]);return e.useSyncExternalStore(e=>r.subscribe(e),()=>r.get(),()=>r.get())},resolve:t=>{const r=b.watch(t);return e.useSyncExternalStore(e=>r.subscribe(()=>e()),()=>r.get(),()=>r.get())},actions:S,isReady:s,store:o,observer:d,actionTracker:m,get state(){return r}}}};
|
package/index.d.cts
CHANGED
|
@@ -96,9 +96,9 @@ type LoadingState<TActions> = Partial<Record<keyof TActions, boolean>>;
|
|
|
96
96
|
*
|
|
97
97
|
* @template T The shape of the store state.
|
|
98
98
|
*/
|
|
99
|
-
type StoreOptions<
|
|
99
|
+
type StoreOptions<TState extends Object> = ObserverOptions & {
|
|
100
100
|
enableMetrics?: boolean;
|
|
101
|
-
persistence?: SimplePersistence<
|
|
101
|
+
persistence?: SimplePersistence<TState>;
|
|
102
102
|
};
|
|
103
103
|
/**
|
|
104
104
|
* A function that transforms a state update before it is committed.
|
|
@@ -147,7 +147,7 @@ interface StoreDefinition<TState extends object, TArtifactsMap extends Artifacts
|
|
|
147
147
|
* @template TArtifactsMap The map of artifact definitions.
|
|
148
148
|
* @template TActions The map of action definitions.
|
|
149
149
|
*/
|
|
150
|
-
type StoreHook<TState extends object, TArtifactsMap extends ArtifactsMap<TState>, TActions extends ActionMap<TState, TArtifactsMap>> = () => {
|
|
150
|
+
type StoreHook<TState extends object, TArtifactsMap extends ArtifactsMap<TState>, TActions extends ActionMap<TState, TArtifactsMap>> = (defaults?: DeepPartial<TState>) => {
|
|
151
151
|
/** Internal store instance. */
|
|
152
152
|
store: ReactiveDataStore<TState>;
|
|
153
153
|
/** Internal observer instance. */
|
|
@@ -186,6 +186,6 @@ type StoreHook<TState extends object, TArtifactsMap extends ArtifactsMap<TState>
|
|
|
186
186
|
state: () => TState;
|
|
187
187
|
};
|
|
188
188
|
|
|
189
|
-
declare function createStore<TState extends Record<string, unknown>, TArtifactsMap extends ArtifactsMap<TState>, TActions extends ActionMap<TState, TArtifactsMap>>(definition: StoreDefinition<TState, TArtifactsMap, TActions>,
|
|
189
|
+
declare function createStore<TState extends Record<string, unknown>, TArtifactsMap extends ArtifactsMap<TState>, TActions extends ActionMap<TState, TArtifactsMap>>(definition: StoreDefinition<TState, TArtifactsMap, TActions>, config?: StoreOptions<any>): StoreHook<TState, TArtifactsMap, TActions>;
|
|
190
190
|
|
|
191
191
|
export { type ActionContext, type ActionImplementation, type ActionMap, type ArtifactScope, type ArtifactsMap, type BoundActions, type LoadingState, type StoreDefinition, type StoreHook, type StoreOptions, type Transformer, type Validator, createStore };
|
package/index.d.ts
CHANGED
|
@@ -96,9 +96,9 @@ type LoadingState<TActions> = Partial<Record<keyof TActions, boolean>>;
|
|
|
96
96
|
*
|
|
97
97
|
* @template T The shape of the store state.
|
|
98
98
|
*/
|
|
99
|
-
type StoreOptions<
|
|
99
|
+
type StoreOptions<TState extends Object> = ObserverOptions & {
|
|
100
100
|
enableMetrics?: boolean;
|
|
101
|
-
persistence?: SimplePersistence<
|
|
101
|
+
persistence?: SimplePersistence<TState>;
|
|
102
102
|
};
|
|
103
103
|
/**
|
|
104
104
|
* A function that transforms a state update before it is committed.
|
|
@@ -147,7 +147,7 @@ interface StoreDefinition<TState extends object, TArtifactsMap extends Artifacts
|
|
|
147
147
|
* @template TArtifactsMap The map of artifact definitions.
|
|
148
148
|
* @template TActions The map of action definitions.
|
|
149
149
|
*/
|
|
150
|
-
type StoreHook<TState extends object, TArtifactsMap extends ArtifactsMap<TState>, TActions extends ActionMap<TState, TArtifactsMap>> = () => {
|
|
150
|
+
type StoreHook<TState extends object, TArtifactsMap extends ArtifactsMap<TState>, TActions extends ActionMap<TState, TArtifactsMap>> = (defaults?: DeepPartial<TState>) => {
|
|
151
151
|
/** Internal store instance. */
|
|
152
152
|
store: ReactiveDataStore<TState>;
|
|
153
153
|
/** Internal observer instance. */
|
|
@@ -186,6 +186,6 @@ type StoreHook<TState extends object, TArtifactsMap extends ArtifactsMap<TState>
|
|
|
186
186
|
state: () => TState;
|
|
187
187
|
};
|
|
188
188
|
|
|
189
|
-
declare function createStore<TState extends Record<string, unknown>, TArtifactsMap extends ArtifactsMap<TState>, TActions extends ActionMap<TState, TArtifactsMap>>(definition: StoreDefinition<TState, TArtifactsMap, TActions>,
|
|
189
|
+
declare function createStore<TState extends Record<string, unknown>, TArtifactsMap extends ArtifactsMap<TState>, TActions extends ActionMap<TState, TArtifactsMap>>(definition: StoreDefinition<TState, TArtifactsMap, TActions>, config?: StoreOptions<any>): StoreHook<TState, TArtifactsMap, TActions>;
|
|
190
190
|
|
|
191
191
|
export { type ActionContext, type ActionImplementation, type ActionMap, type ArtifactScope, type ArtifactsMap, type BoundActions, type LoadingState, type StoreDefinition, type StoreHook, type StoreOptions, type Transformer, type Validator, createStore };
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useSyncExternalStore as e}from"react";import{ReactiveDataStore as t,StoreObserver as s}from"@asaidimu/utils-store";import{ArtifactContainer as r}from"@asaidimu/utils-artifacts";var a=class{executions=[];maxHistory=100;listeners=new Set;track(e){this.executions.unshift(e),this.executions.length>this.maxHistory&&this.executions.pop(),this.notify()}getExecutions(){return[...this.executions]}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){this.listeners.forEach(e=>e())}};function i(i,{enableMetrics:
|
|
1
|
+
import{useSyncExternalStore as e}from"react";import{ReactiveDataStore as t,StoreObserver as s}from"@asaidimu/utils-store";import{ArtifactContainer as r}from"@asaidimu/utils-artifacts";var a=class{executions=[];maxHistory=100;listeners=new Set;track(e){this.executions.unshift(e),this.executions.length>this.maxHistory&&this.executions.pop(),this.notify()}getExecutions(){return[...this.executions]}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){this.listeners.forEach(e=>e())}};function i(i,n){const{enableMetrics:o,...c}=n||{},u=new t(i.state,c.persistence),m=Object.keys(i.actions).reduce((e,t)=>(e[t]=!1,e),{}),d=new t(m),l=o?new s(u,c):void 0,f=o?new a:void 0;u.on("action:start",({name:e})=>{d.set(()=>({[e]:!0}))}),u.on("action:complete",e=>{d.set(()=>({[e.name]:!1})),o&&f&&f.track({id:e.actionId,name:e.name,params:e.params,startTime:e.startTime,endTime:e.endTime,duration:e.duration,status:"success",result:e.result})}),u.on("action:error",e=>{d.set(()=>({[e.name]:!1})),o&&f&&f.track({id:e.actionId,name:e.name,params:e.params,startTime:e.startTime,endTime:e.endTime,duration:e.duration,status:"error",error:e.error})});const h=e=>(u.isReady()&&e(),u.on("persistence:ready",e)),b=()=>u.isReady(),p=new r(u),y=p.resolve.bind(p);i.artifacts&&Object.entries(i.artifacts).forEach(([e,t])=>{p.register({key:e,factory:t.factory,scope:t.scope,lazy:t.lazy})}),i.transform&&Object.entries(i.transform).forEach(([e,t])=>{u.use({name:e,action:(e,s)=>t({state:e,resolve:y},s)})}),i.validate&&Object.entries(i.validate).forEach(([e,t])=>{u.use({block:!0,name:e,action:(e,s)=>t({state:e,resolve:y},s)})});const g=Object.entries(i.actions).reduce((e,[t,s])=>(u.register({name:t,fn:(e,...t)=>s({state:e,resolve:y},...t)}),e[t]=(...e)=>u.dispatch(t,...e),e),{});return function(t){t&&u.set(t);const s=()=>e(e=>u.watch("",e),()=>u.get(),()=>u.get()),r=e(h,b,b);return{select:t=>{const s=u.select(t);return e(e=>s.subscribe(e),()=>s.get(),()=>s.get())},watch:t=>{const s=d.select(e=>e[t]);return e(e=>s.subscribe(e),()=>s.get(),()=>s.get())},resolve:t=>{const s=p.watch(t);return e(e=>s.subscribe(()=>e()),()=>s.get(),()=>s.get())},actions:g,isReady:r,store:u,observer:l,actionTracker:f,get state(){return s}}}}export{i as createStore};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asaidimu/react-store",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Efficient react state manager.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@asaidimu/utils-artifacts": "^3.1.
|
|
30
|
-
"@asaidimu/utils-persistence": "^
|
|
29
|
+
"@asaidimu/utils-artifacts": "^3.1.7",
|
|
30
|
+
"@asaidimu/utils-persistence": "^3.0.0",
|
|
31
31
|
"@asaidimu/utils-store": "^7.0.1",
|
|
32
32
|
"react": "^19.2.1"
|
|
33
33
|
}
|