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/README.md
+10-5Lines changed: 10 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,15 +23,14 @@ The `createPersistMiddleware()` parameters are:
23
23
- a load method
24
24
- (optional) whether to enable debug or not
25
25
26
-
The structure of your store consist of an array that takes some objects, and each object has to follow the following schema:
26
+
The structure of your store consist of an object that takes some objects, and each object has to follow the following schema:
27
27
28
28
- The key of each value in the persist object should match your store shape, a nested reducer would be defined as such: `data.device`.
29
29
- In the `values` key, you can customize which values the package will keep track of. If nothing is provided to the `values` field, all fields will be saved.
30
30
- A `key` is required to be defined for each persisted reducer, this will be used as the async storage key, it keeps a static map of your data which is independent of its shape, which is useful as your application grows.
31
31
- An optional key of `action` can be defined to explicitly declare which action type should trigger a load of that reducer, without this value each load type is generated automatically from the state shape. e.g. to load `"data.device"` fire `LOAD_DATA_DEVICE`, to load `"subscriptionOrders"` fire `LOAD_SUBSCRIPTION_ORDERS`.
32
32
- An optional `automatic` key can also be provided to specify if that reducer should be loaded automatically, without having to dispatch the action. It defaults to `true`.
33
33
34
-
35
34
For the load and save method, you don't have to write them by yourself, they are [available as separate packages below](#providers).
Instructions on how to create this object are above.
42
+
You define the structure that you want to save
43
+
in this object, and then pass it as an argument.
44
+
Instructions on how to create this object are above.
46
45
*/
47
46
conststructure= {
48
47
orders: {
@@ -85,6 +84,12 @@ export const store = createStore(
85
84
86
85
Your reducer data will automatically saved when the values are changed. You can load each reducer using its load action (to see all the load actions generated in your console set the fourth parameter of `createPersistMachine` to `true`).
87
86
87
+
After setting the middleware in the store, you need to call `createPersistMachine.run` and pass the store as an argument.
88
+
89
+
```js
90
+
createPersistMachine.run(store)
91
+
```
92
+
88
93
### Loading Data
89
94
90
95
You can receive actions in your reducers. The code below will apply the saved state to your current state:
0 commit comments