You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DOCS.md
+89-79Lines changed: 89 additions & 79 deletions
Original file line number
Diff line number
Diff line change
@@ -9,69 +9,77 @@
9
9
-[delete][5]
10
10
-[Parameters][6]
11
11
-[getState][7]
12
-
-[useStore][8]
13
-
-[Parameters][9]
14
-
-[Examples][10]
15
-
-[useSetStoreValue][11]
16
-
-[Parameters][12]
17
-
-[Examples][13]
18
-
-[useDeleteStoreValue][14]
19
-
-[Parameters][15]
20
-
-[Examples][16]
21
-
-[useGetAndSet][17]
22
-
-[Parameters][18]
23
-
-[Examples][19]
24
-
-[useGetAndDelete][20]
25
-
-[Parameters][21]
26
-
-[Examples][22]
27
-
-[useSetAndDelete][23]
28
-
-[Parameters][24]
29
-
-[Examples][25]
30
-
-[useStoreValue][26]
31
-
-[Parameters][27]
32
-
-[useStoreState][28]
33
-
-[Examples][29]
34
-
-[rawStore][30]
35
-
-[withStore][31]
36
-
-[Parameters][32]
37
-
-[Examples][33]
12
+
-[listernerMiddleware][8]
13
+
-[useStore][9]
14
+
-[Parameters][10]
15
+
-[Examples][11]
16
+
-[useSetStoreValue][12]
17
+
-[Parameters][13]
18
+
-[Examples][14]
19
+
-[useDeleteStoreValue][15]
20
+
-[Parameters][16]
21
+
-[Examples][17]
22
+
-[useGetAndSet][18]
23
+
-[Parameters][19]
24
+
-[Examples][20]
25
+
-[useGetAndDelete][21]
26
+
-[Parameters][22]
27
+
-[Examples][23]
28
+
-[useSetAndDelete][24]
29
+
-[Parameters][25]
30
+
-[Examples][26]
31
+
-[useStoreValue][27]
32
+
-[Parameters][28]
33
+
-[useStoreState][29]
34
+
-[Examples][30]
35
+
-[rawStore][31]
36
+
-[withStore][32]
37
+
-[Parameters][33]
38
+
-[Examples][34]
38
39
39
40
## reset
40
41
41
42
Resets the state to the given input.
42
43
43
44
### Parameters
44
45
45
-
-`state`**[Object][34]** the new value to reset the state to.
46
+
-`state`**[Object][35]** the new value to reset the state to.
46
47
47
48
## set
48
49
49
50
Sets the specified key in the store. This function is equivaluent to the `useSetStoreValue` hook.
50
51
51
52
### Parameters
52
53
53
-
-`key`**[string][35]** the property to set in the store
54
-
-`value`**[Object][34]** the value of the property
54
+
-`key`**[string][36]** the property to set in the store
55
+
-`value`**[Object][35]** the value of the property
55
56
56
57
## delete
57
58
58
59
delete the specified key from the store. This function is equivaluent to the `useDeleteStoreValue` hook.
59
60
60
61
### Parameters
61
62
62
-
-`key`**[string][35]** the property to set in the store
63
+
-`key`**[string][36]** the property to set in the store
63
64
64
65
## getState
65
66
66
67
Returns **any** the global state value of the store
67
68
69
+
## listernerMiddleware
70
+
71
+
**Meta**
72
+
73
+
-**deprecated**: Use listenerMiddleware
74
+
75
+
68
76
## useStore
69
77
70
78
`useStore` is a React Hook that access a value stored in the application global store. It returns the value, a function to update it (like React.useState) and a function to delete it.
71
79
72
80
### Parameters
73
81
74
-
-`key`**[string][35]** The lookup key to find the saved value in the store
82
+
-`key`**[string][36]** The lookup key to find the saved value in the store
75
83
-`defaultValue`**any** The value if the value in the store is missing
Returns **[array][36]** an array with length 3:<br>
94
+
Returns **[array][37]** an array with length 3:<br>
87
95
position 0 - the value of the data in the store.<br>
88
96
position 1 - a function _setValue_ to modify the data in the store. When used, this function return a promise that resolve nothing, thus you can use `setValue('a value').then(() => {doSomething() //when the store did update})`<br>
89
97
position 2 - a function _deleteValue_ to delete the value from the store. When used, this function return a promise that resolve nothing, thus you can use `deleteValue('a value').then(() => {doSomething() //when the store did update})`
@@ -94,7 +102,7 @@ Returns a function to set or update a variable in the store. You want to use thi
94
102
95
103
### Parameters
96
104
97
-
-`key`**[string][35]** the name of the variable to set in the store
105
+
-`key`**[string][36]** the name of the variable to set in the store
Returns **[Function][37]** a function to set a variable in the store with the given name When used, this function return a promise that resolve nothing, thus you can use `setValue('a value').then(() => {doSomething() //when the store did update})`
115
+
Returns **[Function][38]** a function to set a variable in the store with the given name When used, this function return a promise that resolve nothing, thus you can use `setValue('a value').then(() => {doSomething() //when the store did update})`
108
116
109
117
## useDeleteStoreValue
110
118
111
119
Returns a function to delete a variable in the store. You want to use this hook when you just need to delete a value in the store, not read or set a value from it.
112
120
113
121
### Parameters
114
122
115
-
-`key`**[string][35]** the name of the variable to set in the store
123
+
-`key`**[string][36]** the name of the variable to set in the store
Returns **[Function][37]** a function to delete a variable in the store with the given name. When used, this function return a promise that resolve nothing, thus you can use `deleteValue('a value').then(() => {doSomething() //when the store did update})`
133
+
Returns **[Function][38]** a function to delete a variable in the store with the given name. When used, this function return a promise that resolve nothing, thus you can use `deleteValue('a value').then(() => {doSomething() //when the store did update})`
126
134
127
135
## useGetAndSet
128
136
@@ -131,7 +139,7 @@ This React hook returns an array to read and modify a value in the store:
131
139
132
140
### Parameters
133
141
134
-
-`key`**[string][35]** The lookup key to find the saved value in the store
142
+
-`key`**[string][36]** The lookup key to find the saved value in the store
135
143
-`defaultValue`**any** The default value if missing
Returns **[array][36]** an array with length 2:<br>
156
+
Returns **[array][37]** an array with length 2:<br>
149
157
position 0 - the value of the data in the store.<br>
150
158
position 1 - a function _setValue_ to modify the data in the store. When used, this function return a promise that resolve nothing, thus you can use `setValue('a value').then(() => {doSomething() //when the store did update})`<br>
151
159
@@ -156,7 +164,7 @@ This React hook returns an array to read and delete a value in the store:
156
164
157
165
### Parameters
158
166
159
-
-`key`**[string][35]** The lookup key to find the saved value in the store
167
+
-`key`**[string][36]** The lookup key to find the saved value in the store
Returns **[array][36]** an array with length 2:<br>
178
+
Returns **[array][37]** an array with length 2:<br>
171
179
position 0 - the value of the data in the store.<br>
172
180
position 1 - a function _deleteValue_ to delete the data in the store. When used, this function return a promise that resolve nothing, thus you can use `deleteValue('a value').then(() => {doSomething() //when the store did update})`<br>
173
181
@@ -178,7 +186,7 @@ This React hook returns an array to set and delete a value in the store:
178
186
179
187
### Parameters
180
188
181
-
-`key`**[string][35]** The lookup key to find the saved value in the store
189
+
-`key`**[string][36]** The lookup key to find the saved value in the store
Returns **[array][36]** an array with length 2:<br>
200
+
Returns **[array][37]** an array with length 2:<br>
193
201
position 0 - a function _setValue_ to modify the data in the store. When used, this function return a promise that resolve nothing, thus you can use `setValue('a value').then(() => {doSomething() //when the store did update})`<br>
194
202
position 1 - a function _deleteValue_ to delete the data in the store. When used, this function return a promise that resolve nothing, thus you can use `deleteValue('a value').then(() => {doSomething() //when the store did update})`<br>
195
203
196
204
## useStoreValue
197
205
198
206
### Parameters
199
207
200
-
-`key`**[string][35]** the name of the variable / value to be retrieved in the global store.
208
+
-`key`**[string][36]** the name of the variable / value to be retrieved in the global store.
201
209
-`defaultValue`**any?** an optional default value, if the value in the global store is not present.
202
210
203
211
Returns **any** the value on the global store, or the default value if passed, or `undefined`
@@ -214,7 +222,7 @@ const store = useStoreState()
214
222
console.log('the store is', JSON.stringify(store))
215
223
```
216
224
217
-
Returns **[object][34]** An object representing the whole store value in read only mode.
225
+
Returns **[object][35]** An object representing the whole store value in read only mode.
218
226
219
227
## rawStore
220
228
@@ -225,10 +233,10 @@ This store can be used outside of React components.
225
233
### Parameters
226
234
227
235
-`WrappedComponent`**ReactElement** the component to connect with the store
228
-
-`initialValue`**[Object][34]** an Object that will be the initial store value, or nothing
229
-
-`config`**[Object][34]** the custom configuration. If nothing is passed, the default config will be used.
230
-
-`config.listener`**[Function][37]** a function that is triggered each time the global state is modified. This function takes these parameters: (state, key, prevValue, nextValue). `state` is the value of the new state, `key` is the key that changed, `prevValue` is the old value of the key, `nextValule` is the new one.
231
-
-`config.logging`**[boolean][38]** default `false` - if true it will log changes to console
236
+
-`initialValue`**[Object][35]** an Object that will be the initial store value, or nothing
237
+
-`config`**[Object][35]** the custom configuration. If nothing is passed, the default config will be used.
238
+
-`config.listener`**[Function][38]** a function that is triggered each time the global state is modified. This function takes these parameters: (state, key, prevValue, nextValue). `state` is the value of the new state, `key` is the key that changed, `prevValue` is the old value of the key, `nextValule` is the new one.
239
+
-`config.logging`**[boolean][39]** default `false` - if true it will log changes to console
0 commit comments