Skip to content

Commit 53e7f08

Browse files
adding missing parts
1 parent 3cade0f commit 53e7f08

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

docs/README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@ The `createPersistMiddleware()` parameters are:
2323
- a load method
2424
- (optional) whether to enable debug or not
2525

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:
2727

2828
- The key of each value in the persist object should match your store shape, a nested reducer would be defined as such: `data.device`.
2929
- 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.
3030
- 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.
3131
- 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`.
3232
- 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`.
3333

34-
3534
For the load and save method, you don't have to write them by yourself, they are [available as separate packages below](#providers).
3635

3736
```js
@@ -40,9 +39,9 @@ const saveState = (key, state) => ...
4039
const loadState = (key) => ...
4140

4241
/**
43-
You define the structure that you want to save
44-
in this object, and then pass it as an argument.
45-
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.
4645
*/
4746
const structure = {
4847
orders: {
@@ -85,6 +84,12 @@ export const store = createStore(
8584

8685
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`).
8786

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+
8893
### Loading Data
8994

9095
You can receive actions in your reducers. The code below will apply the saved state to your current state:

0 commit comments

Comments
 (0)