1.1.0 • Published 7 years ago

reducer-generator-reducer v1.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

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

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) */ 
)