combined-reducers-ngrx

2.0.5 • Public • Published

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!

Package Sidebar

Install

npm i combined-reducers-ngrx

Weekly Downloads

21

Version

2.0.5

License

ISC

Unpacked Size

2.38 kB

Total Files

3

Last publish

Collaborators

  • lenii