state-jet 2.0.7 → 2.0.8

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 +16 -15
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- A zero-boilerplate, ultra-fast global state management library for React. No context, reducers, or providers—just simple reactive state.
1
+ A zero-boilerplate, ultra-fast global state management library for React.
2
2
 
3
3
  For more details, see [here](https://statejet.netlify.app).
4
4
 
@@ -41,7 +41,7 @@ Or if you're using `cdn`:
41
41
 
42
42
  ## Basic Example Usage
43
43
 
44
- ```bash
44
+ ```tsx
45
45
  import { useStateGlobal } from "state-jet";
46
46
 
47
47
  const counter = useStateGlobal("counter", 0);
@@ -51,7 +51,7 @@ function Counter() {
51
51
  return <button onClick={() => counter.set(count + 1)}>Count: {count}</button>;
52
52
  }
53
53
  ```
54
- ## Why state-jet Is More Advanced Than Zustand
54
+ ## Why state-jet Is More Advanced Than Zustand
55
55
 
56
56
  - **No Proxies Needed** → Zustand uses proxies for state updates, but state-jet uses signals, making it even faster.
57
57
  - **Derived State Is Automatic** → No need for selectors; state updates only trigger where necessary.
@@ -65,20 +65,21 @@ If you need the simplest, fastest, and most advanced state management solution f
65
65
 
66
66
  ## Create Slice
67
67
 
68
- ```bash
68
+ ```tsx
69
69
  import { useSlice } from "state-jet";
70
70
 
71
- export const useProductSlice = () => useSlice("products")("list", []);
72
-
73
- export const useCartSlice = () =>
74
- useSlice("cart")("items", []);
71
+ const productSlice = useSlice("products");
72
+ const cartSlice = useSlice("cart");
73
+ const userSlice = useSlice("user");
75
74
 
76
- export const useUserSlice = () => useSlice("user")("info", null);
75
+ export const useProductSlice = () => productSlice("list", []);
76
+ export const useCartSlice = () => cartSlice("items", []);
77
+ export const useUserSlice = () => userSlice("info", null);
77
78
  ```
78
79
 
79
80
  ## Create Store
80
81
 
81
- ```bash
82
+ ```tsx
82
83
  import { useStore } from "state-jet";
83
84
  import { useProductSlice, useCartSlice, useUserSlice } from "./slices";
84
85
 
@@ -106,7 +107,7 @@ function useStateGlobal<T>(
106
107
 
107
108
  You can log your store for every action.
108
109
 
109
- ```bash
110
+ ```tsx
110
111
  import { useStateGlobal } from "state-jet";
111
112
 
112
113
  const loggerMiddleware = (key: string, prev: number, next: number) => {
@@ -132,7 +133,7 @@ export default function Counter() {
132
133
 
133
134
  Can't live without reducer?. No worries. StateJet supports reducer middleware
134
135
 
135
- ```bash
136
+ ```tsx
136
137
  import { useStateGlobal } from "state-jet";
137
138
 
138
139
  type Action<T> = { type: string; payload?: T };
@@ -176,7 +177,7 @@ export default function Counter() {
176
177
 
177
178
  You can optimistically update global state with rollback support
178
179
 
179
- ```bash
180
+ ```tsx
180
181
  import { useStateGlobal } from "state-jet";
181
182
 
182
183
  const optimisticMiddleware = (apiUrl: string) => {
@@ -204,7 +205,7 @@ const profile = useStateGlobal("profile", { name: "John" }, {
204
205
 
205
206
  You can create your own custom middleware in state-jet
206
207
 
207
- ```bash
208
+ ```tsx
208
209
  import { useStateGlobal } from "state-jet";
209
210
 
210
211
  const validateAgeMiddleware = (key: string, prev: number, next: number) => {
@@ -239,7 +240,7 @@ A more complete middleware usage is [here](https://statejet.netlify.app/docs/api
239
240
 
240
241
  Here is the example for creating global state with typescript definition.
241
242
 
242
- ```bash
243
+ ```tsx
243
244
  interface Todo = {
244
245
  id: number;
245
246
  text: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "state-jet",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "description": "Ultra-lightweight global state management for React",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",