Skip to content

Instantly share code, notes, and snippets.

@markerikson
Created July 4, 2016 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markerikson/ff8111e25490902f9ba4d00650a70fd8 to your computer and use it in GitHub Desktop.
Save markerikson/ff8111e25490902f9ba4d00650a70fd8 to your computer and use it in GitHub Desktop.
Redux shared reducer data example
import {combineReducers} from "redux";
import reduceReducers from "reduce-reducers";
import reducerA from "./reducerA";
import reducerB from "./reducerB";
import specialCaseHandler from "./specialCaseHandler";
const combinedReducer = combineReducers({
a : reducerA,
b : reducerB
});
function globalSharedBehaviorReducer(state, action) {
switch(action.type) {
case SOME_SPECIFIC_ACTION : {
const newA = specialCaseHandler(state.a, state.b);
return {
...state,
a : newA
};
}
}
}
const rootReducer = reduceReducers(combinedReducer, globalSharedBehaviorReducer);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment