當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript redux-persist.autoRehydrate函數代碼示例

本文整理匯總了TypeScript中redux-persist.autoRehydrate函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript autoRehydrate函數的具體用法?TypeScript autoRehydrate怎麽用?TypeScript autoRehydrate使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了autoRehydrate函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: actionBuffer

const makeStore = (preloadedState = {}) => {
  // ======================================================
  // Middleware Configuration
  // ======================================================
  const middleware = [thunk, actionBuffer(REHYDRATE)]

  // ======================================================
  // Store Enhancers
  // ======================================================
  const enhancers = [autoRehydrate()]
  if (__DEBUG__) {
    const devToolsExtension = window.devToolsExtension
    if (typeof devToolsExtension === 'function') {
      enhancers.push(devToolsExtension())
    }
  }

  // ======================================================
  // Store Instantiation and HMR Setup
  // ======================================================
  const store = createStore(
    reducers(),
    preloadedState,
    compose(
      applyMiddleware(...middleware),
      ...enhancers
    )
  )

  persistState({ store })

  if (module.hot) {
    module.hot.accept('./stateManager', () => {
      const newReducers = require('./stateManager').default
      store.replaceReducer(newReducers)
    })
  }

  return store
}
開發者ID:spartansystems,項目名稱:booster-kit-react,代碼行數:40,代碼來源:createStore.ts

示例2: constructor

  constructor(private appRef: ApplicationRef,
              private af: AngularFire,
              private ngRedux: NgRedux<StoreState>,
              private devTools: DevToolsExtension) {
    AppModule.angularFire = af;
    let enhancers = [];
    if (devTools.isEnabled()) {
      enhancers = [ ...enhancers, devTools.enhancer() ];
    }
    const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
    const store: any = createStore(
      rootReducer,
      initialState,
      composeEnhancers(
        applyMiddleware(),
        autoRehydrate()
      )
      );
    persistStore(store);

    ngRedux.provideStore(store);
  }
開發者ID:matantsu,項目名稱:GetPro,代碼行數:22,代碼來源:app.module.ts

示例3: Promise

  return new Promise((resolve, reject) => {
    try {
      const pages = pagesLoaders.map(Page => new Page())

      const initialState = bindInitialState(pages)
      const reducerList = bindReducers(pages)

      const enhancer: any =
        process.env.NODE_ENV === 'development' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
          ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
          : compose
      const sagaMiddleware = createSagaMiddleware()

      const appReducer = combineReducers(reducerList)
      const signOutAction = Actions.SignOut.SIGN_OUT
      const rootReducer = (state: any, action: any) => appReducer(action.type === signOutAction ? {} : state, action)

      const store = createStore(rootReducer, initialState, enhancer(applyMiddleware(sagaMiddleware), autoRehydrate()))

      sagaMiddleware.run(bindSagas(pages))

      persistStore(store, {}, () => resolve({ store, pages }))
    } catch (e) {
      reject(e)
    }
  })
開發者ID:aconly,項目名稱:frost-web,代碼行數:26,代碼來源:store.ts

示例4: require

import * as localForage from 'localforage';
import { persistStore, autoRehydrate } from 'redux-persist';
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import appReducer from '../reducers';

let middleware = [thunk];
let composer: any;

if (process.env.NODE_ENV === 'production') {
  composer = require('redux').compose;
} else {
  const reduxImmutableStateInvariant = require('redux-immutable-state-invariant').default();
  const logger = require('redux-logger').createLogger({
    // ...options
  });
  composer = require('redux-devtools-extension').composeWithDevTools;
  middleware = middleware.concat(reduxImmutableStateInvariant, logger);
}

const store = composer(
  applyMiddleware(...middleware),
  autoRehydrate(),
)(createStore)(appReducer);

persistStore(store, {storage: localForage});

export default store;
開發者ID:andela-sjames,項目名稱:Django-ReactJS-Library-App,代碼行數:28,代碼來源:index.ts

示例5: combineReducers

        )
      if (networkError) console.error(`[Network error]: ${networkError}`)
    }),
    link,
  ]),
  cache,
})

const reducer = combineReducers({
  mainScreen: mainScreenReducer,
  snackbar: snackbarReducer,
} as any)

const composeEnhancers =
  (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
export const store = createStore(reducer, {}, composeEnhancers(autoRehydrate()))

persistStore(store, {
  whitelist: ['mainScreen'],
})

// Subscribe to all status updates, Apollo will automatically update the store using the id.
client
  .subscribe({
    query: gql`
      subscription deviceUpdated {
        deviceUpdated {
          id
          name
          config
        }
開發者ID:Pajn,項目名稱:RAXA,代碼行數:31,代碼來源:store.ts

示例6: createStore

const persistConfig: PersistConfig = {
    blacklist  : ["foo"],
    whitelist  : ["bar"],
    storage    : asyncLocalStorage,
    transforms : [transform],
    debounce   : 1000,
    keyPrefix  : KEY_PREFIX
}

const rehydrateOptions: PersistorRehydrateOptions = { serial : true }

const autoRehydrateConfig: PersistAutoRehydrateConfig<any, any, any> = {
    stateReconcile: (state: any, inboundState: any, reducedState: any, log: boolean) => ({})
}

const store: Store<any> = createStore(reducer, autoRehydrate(autoRehydrateConfig))
const persistor: Persistor = persistStore(store, persistConfig, persistCallback)

purgeStoredState({ whitelist : ["foo"] }, ["bar"])

getStoredState(persistConfig, (err: any, restoredState: any) => {
    const store: Store<any> = createStore(reducer, restoredState)
    const persistor: Persistor = createPersistor(store, persistConfig)
    const secondaryPersistor: Persistor = createPersistor(store, { storage : asyncSessionStorage })
    persistor.pause()
    persistor.resume()
    persistor.purge(["foo", "bar"])
    persistor.rehydrate(restoredState, rehydrateOptions)
})
開發者ID:ArtemZag,項目名稱:DefinitelyTyped,代碼行數:29,代碼來源:redux-persist-tests.ts


注:本文中的redux-persist.autoRehydrate函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。