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


TypeScript react-redux-loading-bar.loadingBarMiddleware函數代碼示例

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


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

示例1: composeEnhancers

const rootStore = () => {
  const store = createStore<RootState>(
    rootReducer,
    composeEnhancers(
      applyMiddleware(
        loadingBarMiddleware(),
        thunk
      )
    )
  )

  return store
}
開發者ID:do7be,項目名稱:lgtm-hub,代碼行數:13,代碼來源:index.ts

示例2: promiseMiddleware

import { createStore, applyMiddleware, compose } from 'redux';
import promiseMiddleware from 'redux-promise-middleware';
import thunkMiddleware from 'redux-thunk';
import reducer, { IRootState } from 'app/shared/reducers';
import DevTools from 'app/config/devtools';
import errorMiddleware from 'app/config/error-middleware';
import notificationMiddleware from 'app/config/notification-middleware';
import loggerMiddleware from 'app/config/logger-middleware';
import { loadingBarMiddleware } from 'react-redux-loading-bar';

const defaultMiddlewares = [
  thunkMiddleware,
  errorMiddleware,
  notificationMiddleware,
  promiseMiddleware(),
  loadingBarMiddleware(),
  loggerMiddleware
];
const composedMiddlewares = middlewares =>
  process.env.NODE_ENV === 'development'
    ? compose(
        applyMiddleware(...defaultMiddlewares, ...middlewares),
        DevTools.instrument()
      )
    : compose(applyMiddleware(...defaultMiddlewares, ...middlewares));
// 創建 Redux store 來存放應用的狀態。
const initialize
  = ((initialState?: IRootState, middlewares = []) => createStore(reducer, initialState, composedMiddlewares(middlewares)));
// 擴展示例:
// 每次 state 更新時,打印日誌
// 注意 subscribe() 返回一個函數用來注銷監聽器
開發者ID:gjik911,項目名稱:git_01,代碼行數:31,代碼來源:store.ts

示例3: makeImmutable

const language = localStorage.getItem("impera-lang") || "en";

const initialData = Object.assign({}, sessionData, { language: language });
const initialSessionState = initialData && makeImmutable(initialData) as ISessionState || undefined;

export let store = Redux.createStore<IState>(
  rootReducer,
  {
    // Pre-populate stored session data
    session: initialSessionState
  } as IState,
  compose(
    Redux.applyMiddleware(
      routerMiddleware(browserHistory as any),
      loadingBarMiddleware({
        promiseTypeSuffixes: [pending(""), success(""), failed("")]
      }),
      promiseMiddleware as any,
      thunkMiddleware.withExtraArgument({
        getCachedClient: getCachedClient,
        createClientWithToken: createClientWithToken,
        getSignalRClient: getSignalRClient
      } as IAsyncActionDependencies),
      (createLogger as any)())));

// Persist session settings to session storage
store.subscribe(debounce(() => {
  const state = store.getState();
  const sessionState = state && state.session;

  if (sessionState) {
開發者ID:cschleiden,項目名稱:imperaplus-client,代碼行數:31,代碼來源:store.ts


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