septor-store-react 0.0.2 → 0.0.4
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 +16 -12
- package/dist/index.js +189 -188
- package/dist/index.umd.cjs +5 -5
- package/package.json +6 -3
- package/src/index.ts +0 -7
- package/src/setUp/GlobalScripts/AbortHandler.ts +0 -13
- package/src/setUp/GlobalScripts/Axios.ts +0 -67
- package/src/setUp/GlobalScripts/useFetch.ts +0 -65
- package/src/setUp/pomStore.jsx +0 -170
- package/tsconfig.json +0 -13
- package/vite.config.ts +0 -23
package/README.MD
CHANGED
|
@@ -108,11 +108,12 @@ setBearerToken({ token: "abc123", expiresIn: 3600 });
|
|
|
108
108
|
Installation
|
|
109
109
|
npm install zustand axios
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
### Usage
|
|
112
112
|
Import the store
|
|
113
113
|
import usePomZStore from "septor-store-react";
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
### Basic Example
|
|
116
|
+
````
|
|
116
117
|
import { useEffect } from "react";
|
|
117
118
|
import usePomZStore from "septor-store-react";
|
|
118
119
|
// stateKey: remember this should be an id
|
|
@@ -135,15 +136,16 @@ export default function Users() {
|
|
|
135
136
|
if (loading) return <p>Loading...</p>;
|
|
136
137
|
|
|
137
138
|
return <p>Users loaded</p>;
|
|
138
|
-
}
|
|
139
|
+
}```
|
|
139
140
|
|
|
140
|
-
|
|
141
|
+
### Store State
|
|
141
142
|
Name Description
|
|
142
143
|
loading Global loading flag
|
|
143
144
|
stateValue Object holding all stored data
|
|
144
145
|
checkQueriesInQue Tracks active API requests
|
|
145
146
|
isThereAnyDataChangeInAform Tracks form/data changes
|
|
146
|
-
|
|
147
|
+
### Available Functions
|
|
148
|
+
```
|
|
147
149
|
setStateValue(key, value)
|
|
148
150
|
|
|
149
151
|
Store any value globally.
|
|
@@ -171,7 +173,7 @@ validateLength({ a: 1 }); // 1
|
|
|
171
173
|
import usePomZStore from "septor-store-react";
|
|
172
174
|
const { stateGeneratorApi } = usePomZStore();
|
|
173
175
|
|
|
174
|
-
|
|
176
|
+
API Handling
|
|
175
177
|
stateGeneratorApi(config, onData)
|
|
176
178
|
|
|
177
179
|
This is the main function you’ll use to fetch API data.
|
|
@@ -191,28 +193,30 @@ stateGeneratorApi(
|
|
|
191
193
|
console.log("Received data:", data);
|
|
192
194
|
}
|
|
193
195
|
);
|
|
194
|
-
|
|
195
|
-
Configuration Options
|
|
196
|
+
```
|
|
197
|
+
### Configuration Options
|
|
196
198
|
Option Description
|
|
197
199
|
stateKey Where data is stored
|
|
198
200
|
req Axios request config
|
|
199
201
|
reload Force API reload
|
|
200
202
|
time Delay before reload (seconds)
|
|
201
203
|
mStore.mUse Enable sessionStorage
|
|
202
|
-
|
|
204
|
+
### Session Storage Cache
|
|
203
205
|
|
|
204
206
|
Enable caching like this:
|
|
205
|
-
|
|
207
|
+
```
|
|
206
208
|
stateGeneratorApi({
|
|
207
209
|
stateKey: "orders",
|
|
208
210
|
req: { url: "/orders" },
|
|
209
211
|
mStore: { mUse: true },
|
|
210
212
|
});
|
|
213
|
+
````
|
|
211
214
|
|
|
212
215
|
|
|
213
|
-
let use the state in other file
|
|
214
|
-
import usePomZStore from "septor-store-react";
|
|
216
|
+
### let use the state in other file
|
|
217
|
+
```import usePomZStore from "septor-store-react";
|
|
215
218
|
const store = usePomZStore();
|
|
219
|
+
```
|
|
216
220
|
store.orders
|
|
217
221
|
|
|
218
222
|
|