text: import { createStore, applyMiddleware, compose } from 'redux';
  import thunk from 'redux-thunk';
  import { createHashHistory } from 'history';
  import { routerMiddleware } from 'react-router-redux';
  import { createEpicMiddleware } from 'redux-observable';
  import { ajax } from 'rxjs/observable/dom/ajax';
  
  import { rootReducer, rootEpic } from '../reducer';
  
  const history = createHashHistory();
  
  const configureStore = (initialState) => {
    // Redux Configuration
    const middleware = [];
    const enhancers = [];
  
    // Thunk Middleware
    middleware.push(thunk);
  
    // Router Middleware
    const router = routerMiddleware(history);
    middleware.push(router);
  
    // Redux Obervable Middleware
    const epicMiddleware = createEpicMiddleware(rootEpic, {
      dependencies: { getJSON: ajax.getJSON }
    });
    middleware.push(epicMiddleware);
  
    // 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__
      : 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) {
      module.hot.accept('../reducer', () =>
        store.replaceReducer(require('../reducer')) // eslint-disable-line global-require
      );
    }
  
    return store;
  };
  
  export default { configureStore, history };
  