combined-reducers-ngrx

Multiple reducers with same state - Redux

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
combined-reducers-ngrx
202.0.55 years ago5 years agoMinified + gzip package size for combined-reducers-ngrx in KB

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! ````