state-jet 2.0.21 → 2.0.22

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 +17 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -130,6 +130,21 @@ export const useProductSlice = () => productSlice("productState", {});
130
130
  export const useCartSlice = () => cartSlice("cartState", {});
131
131
  ```
132
132
 
133
+ ### Multi States in Single Slice
134
+
135
+ ```ts
136
+ // file: src/store/slices.ts
137
+
138
+ import { useSlice } from "state-jet";
139
+
140
+ // Define multiple state values under one slice
141
+ export const useProductSlice = () => ({
142
+ productState: productSlice("productState", {}),
143
+ productFilter: productSlice("productFilter", { search: "", category: "all" }),
144
+ productSort: productSlice("productSort", { order: "asc" }),
145
+ });
146
+ ```
147
+
133
148
  ## Store
134
149
 
135
150
  The `useStore` hook serves as a mechanism to group related slices of state into a cohesive store, enabling modular and organized state management in React applications which are better suited for larger applications with more complex and structured state requirements.
@@ -173,9 +188,9 @@ type CartType = {
173
188
 
174
189
  export const ProductList = () => {
175
190
  const store = useEcommerceStore();
176
- const products: any = store.products;
191
+ const { productState }: any = store.products;
177
192
  const cart: any = store.cart;
178
- const productSliceData: any = products.useState();
193
+ const productSliceData: any = productState.useState();
179
194
  const cartSliceData: any = cart.useState();
180
195
  const productItems: Array<ProductType> = productSliceData?.items || [];
181
196
  const cartItems: Array<CartType> = cartSliceData?.items || [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "state-jet",
3
- "version": "2.0.21",
3
+ "version": "2.0.22",
4
4
  "description": "Ultra-lightweight global state management for React",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",