https://github.com/l2silver/redux-compose-hors
https://github.com/l2silver/redux-compose-hors
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/l2silver/redux-compose-hors
- Owner: l2silver
- Created: 2017-03-07T03:31:22.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-07T04:08:50.000Z (over 9 years ago)
- Last Synced: 2025-05-21T19:53:44.646Z (about 1 year ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
redux-compose-hors
=====================
Compose higher order reducers
[](https://travis-ci.org/l2silver/redux-compose-hors)
## Why
If you use two or more higher order reducers, then the actions of those reducers must follow the same order that the higher order reducers are in. Furthermore, those reducers cannot be nested beyond two degrees.
```
npm install --save redux-compose-hors
```
## Usage
```
import {createStore} from 'redux';
import {batchActions, enableBatching} from 'redux-batched-actions';
import {retypeAction, enableRetyping} from 'redux-retype-actions';
import composeHors from 'redux-compose-hors';
import {createAction} from 'redux-actions';
const doThing = createAction('DO_THING')
const doOther = createAction('DO_OTHER')
function reducer(state, action) {
switch (action.type) {
case 'DO_THING': return 'thing'
case 'DO_OTHER': return 'other'
default: return state
}
}
const store = createStore(composeHors(reducer, enableRetyping, enableBatching), initialState)
const doMultipleThings = retypeAction('DO_MULTIPLE_THINGS', batchActions([doThing(), doOther()]))
const doMultipleThingsTwice = batchActions([doMultipleThings, doMultipleThings])
store.dispatch(doMultipleThingsTwice)
```