Skip to content

Instantly share code, notes, and snippets.

@callmephilip
Created May 18, 2016 16:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save callmephilip/8eca3f1903cdd45d397b4be5ed7c07d9 to your computer and use it in GitHub Desktop.
Save callmephilip/8eca3f1903cdd45d397b4be5ed7c07d9 to your computer and use it in GitHub Desktop.
import globalNavigation from './components/GlobalNavigation/reducer';
import tabs from './components/ApplicationTabs/reducer';
import feed from './components/Feed/reducer';
import { combineReducers } from 'redux-immutable';
const scopeNavigationReducer = (reducer, scopeName) => {
return (state, action) => {
if (action.scope && action.scope !== scopeName) {
return state;
} else {
return reducer(state, action);
}
};
};
const applicationReducers = {
globalNavigation: scopeNavigationReducer(globalNavigation, 'global'),
tabs: scopeNavigationReducer(tabs, 'tabs'),
feed: scopeNavigationReducer(feed, 'feed')
};
export default function createReducer() {
return combineReducers(applicationReducers);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment