combined-reducers-ngrx
v2.0.5
Published
Multiple reducers with same state - Redux
Downloads
53
Maintainers
Readme
COMBINED REDUCER NGRX
*Its very usefull while using multiple reducers to change/update a single state. *Inorder to build a larger reducer file, split the code into defferent reducer files as per the logic and combine them into a single reducer.
Reference : https://github.com/neoito-hub/combined-reducers-ngrx
Usage
Create a inde.reducer file.
import { runCombinedReducer } from 'combined-reducers-ngrx
Get the reducer functions into an array
let combinedReducer = [reducer1, reducer2, reducer3, etc]
let the library get the current state, action and the array of reducers:
return runCombinedReducer(state, action, combinedReducer)
the code must be like the below, In the index.reducer.ts
import { reducer1 } from '..';
import { reducer2 } from '..';
const initialState: any = {};
export function CombinedReducer(
state = initialState,
action: any
): any {
let combinedReducer = [reducer1, reducer2, reducer3];
return runCombinedReducer(state, action, combinedReducer);
}
```
## _Installation_
`npm i combined-reducers-ngrx`
Good luck!