Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
magicdawn committed Sep 6, 2017
1 parent 17e2ef2 commit 94a1438
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,42 +30,46 @@ const finalReducer = reduceReducers(
const store = createStore(initialState, finalReducer, enhancers)
```

### enable this reducer

use any one of these:

- make `action.type` starts with `STANDARD_MERGE_STATE`, this reducer will handle the action
- make `action.standard = true`, this reducer will handle the action


### Action with `payload`

```js
action = {
type,
standard,
payload,
payload: {...},
}
```

|key |type |remark|
|-----------|-----------|------|
| `type` | `String` | if type starts with `STANDARD_MERGE_STATE`, the action payload will be merged to state |
| `standard`| `Boolean` | if `action.standard` is true, the action payload will be merged to state |
| `payload` | `Object` | the data need to be merged to the `store.state` |

more see the [test/simple.js](test/simple.js)
- more see the [test/simple.js](test/simple.js)

### Action with `update`

```js
action = {
type,
standard,
update: {},
update: {...},
}
```

|key |type |remark|
|-----------|-----------|------|
| `type` | `String` | if type starts with `STANDARD_MERGE_STATE`, the action payload will be merged to state |
| `standard`| `Boolean` | if `action.standard` is true, the action payload will be merged to state |
| `update` | `Object` | the `update` operation, will pass to [immutability-helper](https://github.com/kolodny/immutability-helper), equal to `immutabilityHelper(store.state, action.update)` |
| `update` | `Object` | the `update` operation, will pass to [immutability-helper](https://github.com/kolodny/immutability-helper#update), equal to `immutabilityHelper(store.state, action.update)` |

- more see the [test/simple.js](test/update.js)
- see `update` in [immutability-helper](https://github.com/kolodny/immutability-helper) homepage
- see `update` in [immutability-helper](https://github.com/kolodny/immutability-helper#update) homepage


## Changelog
Expand Down

0 comments on commit 94a1438

Please sign in to comment.