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: README.md
+17-25Lines changed: 17 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -22,9 +22,9 @@ npm install @ice/store --save
22
22
23
23
`icestore` is a lightweight React state management library based on hooks. It has the following core features:
24
24
25
-
* Minimal API: Contains 3 APIs, which is easily learnable in 5 minutes.
25
+
* Minimal API: Contains 5 APIs, which is easily learnable in 5 minutes.
26
26
* Predictable: Uses unidirectional data flow (similar to Redux) and allows state mutation only inside actions, allowing data flow to be traced easily.
27
-
* Optimal performance: Decreases the number of view components that rerender when the state changes by creating multiple stores. Rerendering only occurs when the current state is different from the previous state.
27
+
* Optimal performance: Decreases the number of view components that rerender when the state changes by creating multiple stores.
28
28
* Built in async status: Records loading and error status of async actions, simplifying the rendering logic in the view layer.
29
29
30
30
The data flow is as follows:
@@ -173,6 +173,17 @@ Register store config to the global store instance.
173
173
* Return value
174
174
- {object} store instance
175
175
176
+
### applyMiddleware
177
+
178
+
Apply middleware to all the store if the second parameter is not specified,
179
+
otherwise apply middleware the store by namespace.
180
+
181
+
* Parameters
182
+
- middlewares {array} middleware array to be applied
183
+
- namespace {string} store namespace
184
+
* Return value
185
+
- void
186
+
176
187
### useStores
177
188
178
189
Hook to use multiple stores.
@@ -191,34 +202,15 @@ Hook to use a single store.
191
202
* Return value
192
203
- {object} single store instance
193
204
194
-
### toJS
205
+
### getState
195
206
196
-
Recursively convert proxified state object to plain javaScript type.
207
+
Get the latest state of individual store by namespace.
给所有 store 或者指定 namespace 的 store 注册 middleware,如果不指定第 2 个参数,给所有 store 注册 middleware,如果指定第 2 个参数,则给指定 namespace 的 store 注册 middleware,详细用法见[注册方式](#注册方式)
0 commit comments