• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript redux-persist.persistStore函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中redux-persist.persistStore函数的典型用法代码示例。如果您正苦于以下问题:TypeScript persistStore函数的具体用法?TypeScript persistStore怎么用?TypeScript persistStore使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了persistStore函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: createSagaMiddleware

export const configureStore = () => {
  const sagaMiddleware = createSagaMiddleware()
  const logger = createLogger()
  const store = createStore(
    persistReducer({ key: 'reversi', storage, whitelist: ['history'] }, reducer),
    compose(
      applyMiddleware(sagaMiddleware, logger),
      getDevtools()
    )
  )
  const persistor = persistStore(store)

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

  return {
    store,
    persistor,
    runSaga: sagaMiddleware.run,
    close () {
      store.dispatch(END as any)
    }
  }
}
开发者ID:DanSnow,项目名称:react-reversi,代码行数:27,代码来源:store.ts


示例2: 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


示例3: configureStore

export default function configureStore(referenceDataService, blotterService, pricingService, analyticsService, compositeStatusService, executionService, openFin) {
  const middleware = epicMiddleware(referenceDataService, blotterService, pricingService, analyticsService, compositeStatusService, executionService, openFin)

  const store = createStore(
    rootReducer,
    composeWithDevTools(
      applyMiddleware(middleware),
    ),
  )
  persistStore(store)
  return store
}
开发者ID:tdeheurles,项目名称:ReactiveTraderCloud,代码行数:12,代码来源:configureStore.ts


示例4: createStore

const persistEnhancer = () => (createStore) => (
  reducer,
  initialState,
  enhancer,
) => {
  const store = createStore(
    persistReducer(persistConfig, reducer),
    initialState,
    enhancer,
  );
  const persist = persistStore(store, null);
  return {
    persist,
    ...store,
  };
};
开发者ID:SteveTannnnng,项目名称:Mob,代码行数:16,代码来源:app.ts


示例5: function

export default function ({ store, callback, purge }: PersistState) {
  let enableLocalForage = true
  try {
    window.localStorage.setItem('__u', 'u')
  } catch (e) {
    enableLocalForage = false
  }

  const persist = persistStore(store, {
    storage: enableLocalForage ? localForage : memoryStorage,
    whitelist: reducersToPersist
  }, () => {
    if (callback) {
      callback()
    }
  })

  return purge ? persist.purge() : persist
}
开发者ID:spartansystems,项目名称:booster-kit-react,代码行数:19,代码来源:persistState.ts


示例6: 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


示例7: configureStore

export default function configureStore(defaultState?: State) {
  const middlewares = [ravenMiddleware, thunk, requestsMiddleware];

  if (process.env.NODE_ENV === 'development') {
    /* eslint-disable */
    const { createLogger } = require('redux-logger');
    /* eslint-enable */
    const logger = createLogger({
      level: 'info',
      collapsed: true,
      duration: true,
      diff: true,
      // Avoid diffing actions that insert a lot of stuff into the state to prevent console from lagging
      diffPredicate: (getState: GetState, action: FSA) =>
        !action.type.startsWith('FETCH_MODULE_LIST') && !action.type.startsWith('persist/'),
    });
    middlewares.push(logger);
  }

  const storeEnhancer = applyMiddleware(...middlewares);

  const store: Store<State, any> = createStore(
    rootReducer,
    // @ts-ignore TODO: Figure out why undefined isn't accepted
    defaultState,
    composeEnhancers(storeEnhancer),
  );

  if (module.hot) {
    // Enable webpack hot module replacement for reducers
    module.hot.accept('../reducers', () => store.replaceReducer(rootReducer));
  }

  const persistor = persistStore(store);
  return { persistor, store };
}
开发者ID:nusmodifications,项目名称:nusmods,代码行数:36,代码来源:configure-store.ts


示例8: createMigrate

const config = {
    key: 'root',
    blacklist: ['router'],
    storage,
    version: pkg.version,
    migrations: createMigrate(migrations, { debug: false }),
};

export const history = createHistory();

export const persistReducers = persistCombineReducers(config, reducers);

export const middlewares: Middleware[] = [];

if (process.env.NODE_ENV === 'test') {
} else {
    const loggerMiddleware = createLogger();
    middlewares.push(loggerMiddleware);
}

const sagaMiddleware = createSagaMiddleware();
const routerMiddleware = createRouterMiddleware(history);

middlewares.push(sagaMiddleware, routerMiddleware);

export const store: Store<State> = createStore(persistReducers, applyMiddleware(...middlewares));

export const persistor = persistStore(store, null);

sagaMiddleware.run(rootSaga);
开发者ID:EmmaRamirez,项目名称:nuzlocke-generator,代码行数:30,代码来源:index.ts


示例9: 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


示例10: combineReducers

    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


示例11: 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


示例12: createStore

import me, { State as MeState } from 'store/me'
import users, { State as UsersState } from 'store/users'

// Type definitions
export interface State {
  me: MeState
  users: UsersState
}

// Reducers
const reducers = {
  me,
  users
}

// Middleware
const middleware: Middleware[] = [thunk]
if (process.env.NODE_ENV !== 'production') {
  middleware.push(logger)
}

// Store
const store = createStore(
  persistReducer({ key: 'persistStore', storage }, combineReducers(reducers)),
  applyMiddleware(...middleware)
)

// Exports
export default store
export const persistor = persistStore(store)
开发者ID:chaucerbao,项目名称:react-redux-template,代码行数:30,代码来源:index.ts



注:本文中的redux-persist.persistStore函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript redux-promise-middleware.default函数代码示例发布时间:2022-05-25
下一篇:
TypeScript redux-persist.persistReducer函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap