import {createStore, combineReducers, compose, applyMiddleware} from 'redux';
import {routerReducer, routerMiddleware} from 'react-router-redux';
import {reducer as reduxAsyncConnect} from 'redux-connect';
import thunkMiddleware from 'redux-thunk';

function configureStoreCreator(reducers, middleware = [thunkMiddleware]) {
  const reducer = combineReducers({
    routing: routerReducer,
    reduxAsyncConnect,
    ...reducers
  });

  return (forClient, history, initialState = {}) => {
    const devToolsEnhancer = forClient && window.devToolsExtension ? window.devToolsExtension() : f => f;
    return createStore(
      reducer,
      initialState,
      compose(
        applyMiddleware(
          ...middleware,
          routerMiddleware(history)
        ),
        devToolsEnhancer
      )
    );
  };
}

export default configureStoreCreator;

import {createStore, combineReducers, compose, applyMiddleware} from 'redux';
import {routerReducer, routerMiddleware} from 'react-router-redux';
import {reducer as reduxAsyncConnect} from 'redux-connect';
import thunkMiddleware from 'redux-thunk';

function configureStoreCreator(reducers, middleware = () => [thunkMiddleware]) {
  const reducer = combineReducers({
    routing: routerReducer,
    reduxAsyncConnect,
    ...reducers
  });

  return (forClient, history, initialState = {}, req) => {
    const devToolsEnhancer = forClient && window.devToolsExtension ? window.devToolsExtension() : f => f;
    return createStore(
      reducer,
      initialState,
      compose(
        applyMiddleware(
          ...middleware(req),
          routerMiddleware(history)
        ),
        devToolsEnhancer
      )
    );
  };
}

export default configureStoreCreator;

Provision of middleware now requires function to allow request to be passed in on server-side
Provision of middleware now requires function to allow request to be passed in on server-side
