@reduxjs/toolkit#StoreEnhancer TypeScript Examples

The following examples show how to use @reduxjs/toolkit#StoreEnhancer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: configureStore.ts    From react-boilerplate-cra-template with MIT License 6 votes vote down vote up
export function configureAppStore() {
  const reduxSagaMonitorOptions = {};
  const sagaMiddleware = createSagaMiddleware(reduxSagaMonitorOptions);
  const { run: runSaga } = sagaMiddleware;

  // Create the store with saga middleware
  const middlewares = [sagaMiddleware];

  const enhancers = [
    createInjectorsEnhancer({
      createReducer,
      runSaga,
    }),
  ] as StoreEnhancer[];

  const store = configureStore({
    reducer: createReducer(),
    middleware: [...getDefaultMiddleware(), ...middlewares],
    devTools: process.env.NODE_ENV !== 'production',
    enhancers,
  });

  return store;
}
Example #2
Source File: configureStore.ts    From react-boilerplate-cra-template with MIT License 6 votes vote down vote up
export function configureAppStore() {
  const reduxSagaMonitorOptions = {};
  const sagaMiddleware = createSagaMiddleware(reduxSagaMonitorOptions);
  const { run: runSaga } = sagaMiddleware;

  // Create the store with saga middleware
  const middlewares = [sagaMiddleware];

  const enhancers = [
    createInjectorsEnhancer({
      createReducer,
      runSaga,
    }),
  ] as StoreEnhancer[];

  const store = configureStore({
    reducer: createReducer(),
    middleware: [...getDefaultMiddleware(), ...middlewares],
    devTools:
      /* istanbul ignore next line */
      process.env.NODE_ENV !== 'production' ||
      process.env.PUBLIC_URL.length > 0,
    enhancers,
  });

  return store;
}
Example #3
Source File: enhancer.ts    From datart with Apache License 2.0 6 votes vote down vote up
injectReducerEnhancer = (createReducer): StoreEnhancer => {
  return createStore =>
    (...args) => {
      const store = createStore(...args);

      return {
        ...store,
        createReducer,
        injectedReducers: {},
      };
    };
}