Quantcast
Channel: NGRX reducers using the same state object - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by MilV for NGRX reducers using the same state object

$
0
0

This solutionSplitting big reducer into smaller reducersis not exactly to your question in grabbing the same state object.

here my solution that might be solvable:

export const mergeReducers = <TState>(...reducers: ActionReducer<TState>[]): ActionReducer<TState> => {  return (state: TState, action: Action) => {    if (reducers.length === 0) {      throw new Error('At least one reducer is required');    }    return reducers.reduce((initialState, reducer) => {      return reducer(initialState, action);    }, state);  };};

Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>