redux-persist#persistReducer JavaScript Examples

The following examples show how to use redux-persist#persistReducer. 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: index.js    From react-03.03 with MIT License 6 votes vote down vote up
export function initStore (preloadedState = {}) {
	const store = createStore(
		persistReducer(persistConfig, reducer),
		preloadedState,
		composeEnhancers(
        	applyMiddleware(
				ReduxThunk,
				apiMiddleware,
				routerMiddleware(history),
				chatMiddleware,
				botMiddleware
			)
       ),
	)

	const persistor = persistStore(store)
    return { store, persistor }
}
Example #2
Source File: index.js    From react-03.03 with MIT License 6 votes vote down vote up
export function initStore (preloadedState = {}) {
    let store = createStore(
        persistReducer(persistConfig,reducer),
        preloadedState,
        composeEnhancers(applyMiddleware(
            ReduxThunk,
            routerMiddleware(history),
            botMiddleware,
            chatMiddleware
            ))
    )
    let persistor = persistStore(store)
    return { store, persistor }
}
Example #3
Source File: index.js    From web with MIT License 6 votes vote down vote up
store = createStore(schema, {
  name: 'MyAwesomeStore',
  devTools: true,
  reducerEnhancer: reducer =>
    persistReducer(
      {
        key: config.projectKey,
        storage,
      },
      reducer,
    ),
})
Example #4
Source File: index.js    From mediumx with MIT License 6 votes vote down vote up
export default function configureStore(preloadedState) {
  const middlewares = [logger];
  const middlewareEnhancer = applyMiddleware(...middlewares);

  const syncStorageConfig = {
    key: "syncStorage",
    storage: syncStorage
  };

  const persistedReducer = persistReducer(syncStorageConfig, rootReducer);

  let store = createStore(persistedReducer, preloadedState, middlewareEnhancer);

  let persistor = persistStore(store);

  return { store, persistor };
}
Example #5
Source File: store.js    From react-14.01 with MIT License 6 votes vote down vote up
function initStore() {
    const innitialStore = {};
 
    const store = createStore(
        persistReducer(persistConfig, initReducers(history)),
        innitialStore,
        compose(
            applyMiddleware(routerMiddleware(history), ...middlewares),
            window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__() : () => {},
        ),
    );
 
    const persistor = persistStore(store);
 
    return { store, persistor };
 }
Example #6
Source File: store.js    From react-14.01 with MIT License 6 votes vote down vote up
initStore = (preloadedState = {}) => {
  const store = createStore(
    persistReducer(persistConfig, reducer),
    preloadedState,
    compose(
      applyMiddleware(
        routerMiddleware(history),
        logger,
        chatMiddleware,
        botMiddleware,
        apiMiddleware,
        thunk
      ),
      devTools
    )
  );
  const persistor = persistStore(store);
  return {
    store,
    persistor
  };
}
Example #7
Source File: store.js    From react-14.01 with MIT License 6 votes vote down vote up
initStore =(preloadedState = {}) => {
    const innitialStore = {};

    const store = createStore(
        persistReducer(persisitConfig, reducer),
        innitialStore,
        compose(applyMiddleware(routerMiddleware(history), logger, loadMiddleware, addMiddleware, deleteChatMiddleware, switchPageMiddleware, chatMiddleware, botMiddleware, apiMiddleware, thunk), devTools),
    );

    const persistor = persistStore(store);

    return {store, persistor};
    //return createStore(reducer, preloadedState, compose(applyMiddleware(logger, botMiddleware), devTools));
    //return createStore(reducer, preloadedState, compose(applyMiddleware(routerMiddleware(history), logger, loadMiddleware, addMiddleware, switchPageMiddleware, chatMiddleware, botMiddleware), devTools));
}
Example #8
Source File: rootReducer.js    From one-wallet with Apache License 2.0 6 votes vote down vote up
rootReducer = (history) => combineReducers({
  ...reducers,
  wallet: persistReducer({ ...walletPersistConfig, storage }, reducers.wallet),
  cache: persistReducer({ ...cachePersistConfig, storage }, reducers.cache),
  global: persistReducer({ ...globalPersistConfig, storage }, reducers.global),
  balance: persistReducer({ ...balancePersistConfig, storage }, reducers.balance),
  router: connectRouter(history),
  lastAction
})
Example #9
Source File: index.js    From use-shopping-cart with MIT License 6 votes vote down vote up
export function createShoppingCartStore(options) {
  if (!isClient) {
    return configureStore({
      reducer,
      preloadedState: { ...initialState, ...options }
    })
  }
  let storage
  if (isClient) storage = options.storage || createLocalStorage()
  else storage = createNoopStorage()
  delete options.storage

  const persistConfig = {
    key: 'root',
    version: 1,
    storage,
    whitelist: ['cartCount', 'totalPrice', 'formattedTotalPrice', 'cartDetails']
  }
  const persistedReducer = persistReducer(persistConfig, reducer)

  const newInitialState = { ...initialState, ...options }
  updateFormattedTotalPrice(newInitialState)

  return configureStore({
    reducer: persistedReducer,
    preloadedState: newInitialState,
    middleware: (getDefaultMiddleware) =>
      getDefaultMiddleware({
        serializableCheck: {
          ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER]
        }
      }).concat(handleStripe, handleWarnings)
  })
}
Example #10
Source File: index.js    From real-frontend with GNU General Public License v3.0 5 votes vote down vote up
persistedReducer = persistReducer(persistConfig, rootReducer)
Example #11
Source File: store.js    From react-14.01 with MIT License 5 votes vote down vote up
persist = persistReducer(persistConfig, reducer)
Example #12
Source File: store.js    From react-14.01 with MIT License 5 votes vote down vote up
initStore = (preloadedState = {}) => {
	const store = createStore(persistReducer(persistConfig, reducer), preloadedState, compose(applyMiddleware(routerMiddleware(history), chatMiddleware, botMiddleware, apiMiddleware, thunk), devTools));
	const persistor = persistStore(store);
	return {store, persistor};
}
Example #13
Source File: store.js    From react-14.01 with MIT License 5 votes vote down vote up
initStore = (preloadedState = {}) => {
    return createStore(persistReducer(persistConfig,reducer(history)), preloadedState, middlewares)
}
Example #14
Source File: index.js    From full-stack-fastapi-react-postgres-boilerplate with MIT License 5 votes vote down vote up
reducer = persistReducer(
  {
    key: 'rrsb', // key is required
    storage, // storage is now required
    whitelist: ['app', 'user'],
  },
  combineReducers({ ...rootReducer }),
)
Example #15
Source File: index.js    From electron-lightyearvpn with MIT License 5 votes vote down vote up
persistedReducer = persistReducer(persistConfig, rootReducer)
Example #16
Source File: index.js    From instagram-live-streamer with MIT License 5 votes vote down vote up
persistedReducer = persistReducer(persistConfig, InstagramUser)
Example #17
Source File: store.js    From react-tutorial with MIT License 5 votes vote down vote up
persistedReducer = persistReducer(persistConfig, reducer)
Example #18
Source File: App.js    From reactjs-functions with MIT License 5 votes vote down vote up
persistedReducer = persistReducer(persistConfig, reducers)
Example #19
Source File: index.js    From discovery-mobile-ui with MIT License 5 votes vote down vote up
createStore = (authentication) => {
  const { baseUrl, tokenResponse: { accessToken, idToken } } = authentication;

  const fhirClient = new FhirClient(baseUrl, accessToken, idToken);

  const epicMiddleware = createEpicMiddleware({
    dependencies: {
      fhirClient,
    },
  });

  const { patientId } = fhirClient;

  const rootReducer = combineReducers({
    resources: flattenedResourcesReducer,
    associations: associationsReducer,
    activeCollectionId: activeCollectionIdReducer,
    collections: collectionsReducer,
    creatingCollection: isCreatingNewCollectionReducer,
  });

  const persistReducerConfig = {
    version: '0.1.0',
    key: `root-${patientId}`,
    storage: AsyncStorage,
    whitelist: ['activeCollectionId', 'collections', 'creatingCollection'],
  };

  const store = configureStore({
    reducer: persistReducer(persistReducerConfig, rootReducer),
    middleware: compose([
      thunk,
      epicMiddleware,
      // routerMiddleware(history), // < e.g.: other middleware
    ]),
    devTools: {
      serialize: true, // See: https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md#serialize
    },
  });

  epicMiddleware.run(rootEpic);

  const callback = () => {
    // callback function will be called after rehydration is finished.
  };

  const persistConfig = {
    // manualPersist: true,
  };

  const persistor = persistStore(store, persistConfig, callback);

  return {
    store,
    persistor,
  };
}
Example #20
Source File: index.js    From deno-seed with MIT License 5 votes vote down vote up
persistedReducer = persistReducer(persistConfig, rootReducer)
Example #21
Source File: index.js    From tilli-web-app with GNU Affero General Public License v3.0 5 votes vote down vote up
persistedReducer = persistReducer(persistConfig, rootReducer)
Example #22
Source File: configureStore.js    From zubhub with GNU Affero General Public License v3.0 5 votes vote down vote up
persistedReducer = persistReducer(persistConfig, rootReducer)
Example #23
Source File: configureStore.js    From pandoa with GNU General Public License v3.0 5 votes vote down vote up
persistedReducer = persistReducer(persistConfig, rootReducer)
Example #24
Source File: combineReducers.jsx    From ResoBin with MIT License 5 votes vote down vote up
persistedReducer = persistReducer(persistConfig, reducer)
Example #25
Source File: store.js    From notence with MIT License 5 votes vote down vote up
persistedReducer = persistReducer(persistConfig, rootReducer)
Example #26
Source File: index.js    From React-Nest-Admin with MIT License 5 votes vote down vote up
persistedReducer = persistReducer(
  persistConfig,
  createRootReducer(history)
)
Example #27
Source File: store.js    From video-journal-for-teams-fe with MIT License 5 votes vote down vote up
rootReducer = combineReducers({
  User: persistReducer(userPersistConfig, userReducer),
  Team: persistReducer(teamPersistConfig, teamReducer),
  Organization: persistReducer(organizationPersistConfig, organizationReducer),
})
Example #28
Source File: store.js    From video-journal-for-teams-fe with MIT License 5 votes vote down vote up
pReducer = persistReducer(rootPersistConfig, rootReducer)
Example #29
Source File: store.js    From Designer-Client with GNU General Public License v3.0 5 votes vote down vote up
persistedReducer = persistReducer(persistConfig, rootReducer)