Example #1
0
export default function create(client, data) {
  const middleware = [configurePromise(client), thunk];

  if (process.env.NODE_ENV !== 'production') {
    middleware.push(createLogger());
  }

  const finalCreateStore = compose(
    applyMiddleware(...middleware),
    DevTools.instrument()
  )(createStore);

  const asyncReducers = {};
  const reducers = createReducers(asyncReducers);

  const store = finalCreateStore(reducers, data, install());

  if (process.env.NODE_ENV === 'development') {
    if (module.hot) {
      module.hot.accept('common/reducers/create',
        () => store.replaceReducer(createReducers));
    }
  }

  return store;
}
Example #2
0
export default function injectAsyncReducer(store, name, asyncReducer) {
  const tempStore = Object.assign(store, {
    asyncReducers: {
      ...store.asyncReducers,
      [name]: asyncReducer,
    },
  });
  // store.asyncReducers[name] = asyncReducer;
  store.replaceReducer(createReducer(tempStore.asyncReducers));
}