state-jet 2.0.8 → 2.0.9

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 +7 -10
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -70,26 +70,23 @@ import { useSlice } from "state-jet";
70
70
 
71
71
  const productSlice = useSlice("products");
72
72
  const cartSlice = useSlice("cart");
73
- const userSlice = useSlice("user");
74
73
 
75
74
  export const useProductSlice = () => productSlice("list", []);
76
- export const useCartSlice = () => cartSlice("items", []);
77
- export const useUserSlice = () => userSlice("info", null);
75
+ export const useCartSlice = () => cartSlice("list", []);
78
76
  ```
79
77
 
80
78
  ## Create Store
81
79
 
82
80
  ```tsx
83
81
  import { useStore } from "state-jet";
84
- import { useProductSlice, useCartSlice, useUserSlice } from "./slices";
82
+ import { useProductSlice, useCartSlice } from "./slices";
85
83
 
86
84
  const initializer: any = () => ({
87
85
  products: useProductSlice(),
88
86
  cart: useCartSlice(),
89
- user: useUserSlice()
90
87
  });
91
88
 
92
- export const useEcommerceStore = () => useStore(initializer);
89
+ export const store = () => useStore(initializer);
93
90
  ```
94
91
 
95
92
  ## Middlewares
@@ -98,8 +95,8 @@ Unlike other libraries, you do not need to rely on any external dependencies. A
98
95
 
99
96
  ```bash
100
97
  function useStateGlobal<T>(
101
- ...
102
- options?: { middleware?: Middleware<T>[] }
98
+ ...
99
+ options?: { middleware?: [] }
103
100
  )
104
101
  ```
105
102
 
@@ -197,7 +194,7 @@ const optimisticMiddleware = (apiUrl: string) => {
197
194
  };
198
195
  };
199
196
  const profile = useStateGlobal("profile", { name: "John" }, {
200
- middleware: [optimisticMiddleware("/update-profile")],
197
+ middleware: [optimisticMiddleware("/update-profile")],
201
198
  });
202
199
  ```
203
200
 
@@ -225,7 +222,7 @@ export default function Profile() {
225
222
  <h1>Age: {age}</h1>
226
223
  <button
227
224
  onClick={() => {
228
- counter.set(-5) //Age will be 0 eventhough it updated with negative value due to middleware logic
225
+ counter.set(-5) // Age will be 0 eventhough it updated with negative value due to middleware logic
229
226
  }}>
230
227
  Set negative
231
228
  </button>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "state-jet",
3
- "version": "2.0.8",
3
+ "version": "2.0.9",
4
4
  "description": "Ultra-lightweight global state management for React",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",