Created
May 18, 2016 16:16
-
-
Save callmephilip/8eca3f1903cdd45d397b4be5ed7c07d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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