This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

shared-combine-reducers

1.0.1 • Public • Published

A reducer for redux which shares data

Sharing data between slice reducers in Redux can cause some troubles. With this package you can easily share data beween reducers.

Installation

To install the latest version of shared-combine-reducers:

npm install shared-combine-reducers --save

Usage

Replace:

import { combineReducers } from 'redux'
  
const rootReducer = combineReducers({
    reducerA,
    reducerB,
    reducerC
});

with:

import sharedCombineReducers from 'shared-combine-reducers'
  
const rootReducer = sharedCombineReducers({
    reducerA,
    reducerB,
    reducerC
});

in each reducer you now have access to the full previous state and a partial next state:

const reducerC = (state, action, previousFullState, nextState) => {
    
    switch(action.type) {
        case 'ACTION_X1':
            const stateA = nextState.reducerA
            
            // ..
            
            
            return newState
        default:
            return state    
    }
}

Readme

Keywords

Package Sidebar

Install

npm i shared-combine-reducers

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

10.7 kB

Total Files

6

Last publish

Collaborators

  • bennot