export default function configureStore(extEnhancer, subscriber = () => ({}), options = {}) {
  const { deserializeState, deserializeAction } = options;
  return compose(
    extEnhancer,
    instrument(subscriber, window.devToolsOptions),
    persistState(
      getPersistSession(),
      deserializeState,
      deserializeAction
    )
  );
}
Esempio n. 2
0
function getDebugSessionKey() {
  // we can write custom logic here!
  // By default we try to read the key from ?debug_session=<key> in the address bar
  const matches = window.location.href.match(/[?&]debug_session=([^&]+)\b/);
  return (matches && matches.length > 0) ? matches[1] : null;
}

const logger = createLogger();

const enhancer = compose(
  // Middleware we want to use in development:
  applyMiddleware(thunkMiddleware, promiseMiddleware, logger),
  // Required! Enable Redux DevTools with the monitors we chose
  DevTools.instrument(),
  // Optional. Lets we write ?debug_session=<key> in address bar to persist debug sessions
  persistState(getDebugSessionKey())
);

const store = createStore(combineReducers(reducers), undefined, enhancer);
export default store;

// Hot reload reducers with Webpack dev server
if (module.hot) { // FIXME: not working
  module.hot.accept('../reducers/index.js', () => {
    // eslint-disable-next-line global-require
    const newRootReducer = combineReducers(require('../reducers').exports);
    store.replaceReducer(newRootReducer);
    console.info('Reloaded reducers'); // eslint-disable-line no-console
  });
}