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


TypeScript createBrowserHistory.default函數代碼示例

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


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

示例1: function

export default function(paths: PathConfigs<BrowserState> = [], history: History = createBrowserHistory()) {
  let currentPath = locationToPathConfigAndMatch(paths, history.location).path;

  function syncToBrowser(s: BrowserState, push: boolean = true): void {
    (push ? history.push : history.replace)(serializeBrowserState(paths, s));
  }

  function onBrowserChange(callback: (s: BrowserState, action: Action) => void): void {
    history.listen((location, action) => {
      currentPath = locationToPathConfigAndMatch(paths, location).path;
      callback(parseBrowserState(paths, location), action);
    });
    callback(parseBrowserState(paths, history.location), 'PUSH');
  }

  function dryRunBrowserTransition<S extends BrowserState>(s: S): S {
    return cleanupPathParams(s, currentPath, browserStateToPathConfig(paths, s)) as S;
  }

  return { syncToBrowser, onBrowserChange, dryRunBrowserTransition };
}
開發者ID:buildo,項目名稱:state,代碼行數:21,代碼來源:browser.ts

示例2: withProps

import createHistory from "history/createBrowserHistory";
import { withProps } from "recompose";

export default withProps({ history: createHistory() });
開發者ID:1ven,項目名稱:react-boilerplate,代碼行數:4,代碼來源:withHistory.ts

示例3: createBrowserHistory

import { createStore, combineReducers, applyMiddleware } from 'redux';
import { routerReducer, routerMiddleware, RouterState } from 'react-router-redux';
import { default as createSagaMiddleware } from 'redux-saga';
import { mainReducer, MainState } from '../reducers/Main';
import { fbScenarioReducer, FBScenarioState } from '../reducers/FBScenario';
import { logger } from '../middleware/logger';
import createBrowserHistory from 'history/createBrowserHistory';
import { rootSaga } from '../middleware/postScenario';

export const history = createBrowserHistory();
const router = routerMiddleware(history);
const sagaMiddleware = createSagaMiddleware();

export default createStore(
  combineReducers({
    main: mainReducer,
    scenario: fbScenarioReducer,
    router: routerReducer,
  }),
  applyMiddleware(logger, router, sagaMiddleware),
);

sagaMiddleware.run(rootSaga);

export type ReduxState = {
  main: MainState;
  scenario: FBScenarioState;
  router: RouterState;
};
開發者ID:kanecop,項目名稱:react_laravel,代碼行數:29,代碼來源:configureStore.ts

示例4: createHistory

import createHistory from 'history/createBrowserHistory';
const history = createHistory({
    basename: ''
});

export default history;
開發者ID:Ed-wu,項目名稱:basket-mobile,代碼行數:6,代碼來源:history.ts

示例5: createHistory

ifOnlyWeHadTopLevelAwaitAndNotSyncModules(tiles).then(() => {
  const history = createHistory()

  const sagaMiddleware = createSagaMiddleware();

  const store = createStore<State, Action, any, any>(
    reduce,
    (window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose)(
      applyMiddleware(
        thunk,
        sagaMiddleware,
        routerMiddleware(history)
      )
    )
  );

  sagaMiddleware.run(sagas)

  main(store, history);
});
開發者ID:mariusGundersen,項目名稱:Ekkiog,代碼行數:20,代碼來源:start.ts

示例6: createHistory

// tslint:disable
import createHistory from 'history/createBrowserHistory';

// Using browser history (the modern one, without `#`) as `react-router-redux`'s history.
export const history = createHistory();
開發者ID:ofir123,項目名稱:Michelin,代碼行數:5,代碼來源:history.ts

示例7: createHistory

import { routerMiddleware } from 'react-router-redux'
import { applyMiddleware, compose, createStore } from 'redux'
import { createLogger } from 'redux-logger'
import createHistory from 'history/createBrowserHistory'
import createSagasMiddleware from 'redux-saga'

import { createAnalyticsMiddleware } from '@dapps/modules/analytics/middleware'
import { createStorageMiddleware } from '@dapps/modules/storage/middleware'

import { rootReducer } from './reducer'
import { rootSaga } from './sagas'

const composeEnhancers =
  (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose

const history = createHistory()

const historyMiddleware = routerMiddleware(history)
const sagasMiddleware = createSagasMiddleware()
const loggerMiddleware = createLogger({
  collapsed: () => true,
  predicate: (_: any, action) =>
    env.isDevelopment() || action.type.includes('Failure')
})
const analyticsMiddleware = createAnalyticsMiddleware(
  env.get('REACT_APP_SEGMENT_API_KEY')
)
const { storageMiddleware, loadStorageMiddleware } = createStorageMiddleware({
  storageKey: env.get('REACT_APP_LOCAL_STORAGE_KEY', 'decentraland-agora')
})
開發者ID:decentraland,項目名稱:agora,代碼行數:30,代碼來源:store.ts

示例8: createHistory

import createHistory from 'history/createBrowserHistory';
export const firekylinHistory = createHistory({
    basename: process.env.basename
});
開發者ID:75team,項目名稱:firekylin,代碼行數:4,代碼來源:history.ts


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