diff --git a/app/store/configureStore.development.js b/app/store/configureStore.development.js index 99887a7..3677cf5 100644 --- a/app/store/configureStore.development.js +++ b/app/store/configureStore.development.js @@ -4,36 +4,48 @@ import { hashHistory } from 'react-router'; import { routerMiddleware, push } from 'react-router-redux'; import createLogger from 'redux-logger'; import rootReducer from '../reducers'; - import * as counterActions from '../actions/counter'; import type { counterStateType } from '../reducers/counter'; -const actionCreators = { - ...counterActions, - push, -}; - -const logger = createLogger({ - level: 'info', - collapsed: true -}); - -const router = routerMiddleware(hashHistory); - -// If Redux DevTools Extension is installed use it, otherwise use Redux compose -/* eslint-disable no-underscore-dangle */ -const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? - window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({ - // Options: http://extension.remotedev.io/docs/API/Arguments.html - actionCreators, - }) : - compose; -/* eslint-enable no-underscore-dangle */ -const enhancer = composeEnhancers( - applyMiddleware(thunk, router, logger) -); - -export default function configureStore(initialState?: counterStateType) { +export default (initialState: ?counterStateType) => { + // Redux Configuration + const middleware = []; + const enhancers = []; + + // Thunk Middleware + middleware.push(thunk); + + // Logging Middleware + const logger = createLogger({ + level: 'info', + collapsed: true + }); + middleware.push(logger); + + // Router Middleware + const router = routerMiddleware(hashHistory); + middleware.push(router); + + // Redux DevTools Configuration + const actionCreators = { + ...counterActions, + push, + }; + // If Redux DevTools Extension is installed use it, otherwise use Redux compose + /* eslint-disable no-underscore-dangle */ + const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ + ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({ + // Options: http://zalmoxisus.github.io/redux-devtools-extension/API/Arguments.html + actionCreators, + }) + : compose; + /* eslint-enable no-underscore-dangle */ + + // Apply Middleware & Compose Enhancers + enhancers.push(applyMiddleware(...middleware)); + const enhancer = composeEnhancers(...enhancers); + + // Create Store const store = createStore(rootReducer, initialState, enhancer); if (module.hot) { @@ -43,4 +55,4 @@ export default function configureStore(initialState?: counterStateType) { } return store; -} +};