Skip to content

Commit

Permalink
adding example project to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rodriigovieira committed Dec 9, 2020
1 parent d52417d commit 5168429
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,19 @@ Of course, you can also define your own custom action name. This custom action n

The middleware runs: `action.payload = { ...storedData, ...action.payload };` to add the saved data to the payload when the `@ReduxPM/LoadActions` is triggered. You can also pass additional data in your payload to add context to your `@ReduxPM/LoadActions` for complex conditional consummation of the loaded data in your reducers.

### Example Project

There's also an example project that shows `redux-persist-machine` in a real-app alongside with our other package, `redux-nl`. It has multiple reducers that are saved automatically.

[Check the example project!](https://github.com/aspect-apps/redux-nl-example)

## API Reference

### `createPersistMiddleware(structure, saveState, loadState)`

Creates a Redux persist middleware with your store structure.

- `structure: Object` - A object to define how you want to load your reducer values. The key of each value in the persist object should match your store shape, a nested reducer would be defined as such: `data.device`. Currently supported options are:
- `structure: Object` - An object to define how you want to load your reducer values. The key of each value in the persist object should match your store shape, a nested reducer would be defined as such: `data.device`. Currently supported options are:
- `values : Array` you can customize which values the package will keep track of. If nothing is provided to the `values` field, all fields will be saved.
- `key : string` this will be used as the storage key, it keeps a static map of your data which is independent of its shape, which is useful if your reducers change their structure or name.
- `action : string` 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_SUBSCRIPTION_ORDERS`.
Expand Down

0 comments on commit 5168429

Please sign in to comment.