Created
October 21, 2017 04:25
-
-
Save justincorrigible/37cedb3464b88e530c6e932c6e9f1acd to your computer and use it in GitHub Desktop.
This file contains 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
// Main reducer | |
import {combineReducers} from 'redux'; | |
import {routerReducer} from 'react-router-redux'; | |
import WhateverReducer, * as fromWhateverReducer from './reducer-Whatever'; | |
import UIReducer, * as fromUIReducer from './reducer-UI'; | |
import {storeSelector} from 'helpers/'; | |
export const rootReducer = combineReducers({ | |
uiState: UIReducer, | |
whatever: WhateverReducer, | |
router: routerReducer, | |
}); | |
const selectors = { | |
whatever: state => state.whatever, | |
trips: state => state.uiState.searching || state.uiState.filters.length ? | |
storeSelector(state.trips, state.uiState.searching, state.uiState.filters) : | |
state.trips, | |
ui: state => state.uiState, | |
}; | |
export const stateSelector = (selection, state) => { | |
return selectors[selection](state); | |
}; | |
export const isToggled = (state, toggle) => | |
fromUIReducer.isToggled(state.uiState, toggle); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment