An open API service indexing awesome lists of open source software.

https://github.com/dash-os/reducer-generator-reducer

A redux reducer-generator which builds a redux-reducer from a redux-reducer.
https://github.com/dash-os/reducer-generator-reducer

Last synced: 3 months ago
JSON representation

A redux reducer-generator which builds a redux-reducer from a redux-reducer.

Awesome Lists containing this project

README

          

# reducer-generator-reducer

A `reducer-generator` which builds a reducer that reduces a reducer. In most
cases this is not useful. It is, however, useful for libraries that are building
reducers from various object types as it allows us to inject arguments into the
reduction chain.

### Installation

```
yarn add reducer-generator-reducer
```

**or**

```
npm install --save reducer-generator-reducer
```

### Simple Example

```js
import createReducerReducer from 'reducer-generator-reducer'

const system = createReducerReducer(
{ /* initial state */ },
(state, action) => {
switch(action.type) {
case 'SYSTEM_ONLINE': {
return {
...state,
isOnline: true
}
}
case 'SYSTEM_OFFLINE': {
return {
...state,
isOnline: false
}
}
}
return state
},
/* You may pass extra args that will be passed to the reducer(s) */
)
```