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


TypeScript history.createBrowserHistory函數代碼示例

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


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

示例1: makeHistoryDriver

export function makeHistoryDriver(
    options?: BrowserHistoryBuildOptions | History | MemoryHistory,
  ): HistoryDriver {
  let history: any;
  if (options && options.hasOwnProperty('createHref')) {
    history = options;
  } else {
    history = createBrowserHistory(options);
  }

  return function historyDriver(sink$: Stream<HistoryInput | string>) {
    return createHistory$(history, sink$);
  };
}
開發者ID:whitecolor,項目名稱:cyclejs,代碼行數:14,代碼來源:drivers.ts

示例2: createBrowserHistory

import { createBrowserHistory, createMemoryHistory, createHashHistory, createLocation, Location, History, MemoryHistory } from 'history';
import * as LocationUtils from 'history/LocationUtils';
import * as PathUtils from 'history/PathUtils';
import * as DOMUtils from 'history/DOMUtils';
import * as ExecutionEnvironment from 'history/ExecutionEnvironment';

let input = { value: "" };

{
    let history: History<{some: 'state'}> = createBrowserHistory();

    // Listen for changes to the current location. The
    // listener is called once immediately.
    let unlisten = history.listen(function (location) {
        console.log(location.pathname);
    });

    // When you're finished, stop the listener.
    unlisten();

    // Push a new entry onto the history stack.
    history.push('/home');

    // Replace the current entry on the history stack.
    history.replace('/profile');

    // Push a new entry with state onto the history stack.
    history.push({
        pathname: '/about',
        search: '?the=search',
        state: { some: 'state' }
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:history-tests.ts

示例3: goto

 static goto(routePath: string): History {
   const history = createBrowserHistory();
   history.push(`/${routePath}`);
   return history;
 }
開發者ID:nitrogenlabs,項目名稱:nl-flux,代碼行數:5,代碼來源:InspectorActions.ts

示例4: createBrowserHistory

import { createBrowserHistory } from 'history'

const history = createBrowserHistory({
  basename: '/intern',
})

export default history
開發者ID:blindern,項目名稱:intern,代碼行數:7,代碼來源:history.ts

示例5: combineReducers

import { createStore, combineReducers, applyMiddleware } from 'redux';
import { createBrowserHistory } from 'history';
import { syncHistory, routeReducer } from 'react-router-redux';

const reducer = combineReducers({ routing: routeReducer });

// Sync dispatched route actions to the history
const browserHistory = createBrowserHistory()
const reduxRouterMiddleware = syncHistory(browserHistory);
const createStoreWithMiddleware = applyMiddleware(reduxRouterMiddleware)(createStore);

const store = createStoreWithMiddleware(reducer);

// Required for replaying actions from devtools to
reduxRouterMiddleware.listenForReplays(store);
開發者ID:DmitryEfimenko,項目名稱:DefinitelyTyped,代碼行數:15,代碼來源:react-router-redux-tests.ts

示例6: createBrowserHistory

import { createBrowserHistory } from 'history';

const history = createBrowserHistory();
export default history;
開發者ID:weiweiwitch,項目名稱:third-lab,代碼行數:4,代碼來源:appHistory.ts

示例7: qhistory

import qhistory from 'qhistory';
import { createBrowserHistory } from 'history';
import * as qs from 'qs';

const history = qhistory(createBrowserHistory(), qs.stringify, qs.parse);

history.listen(location => {
  const query: { foo?: string } = location.query;
  if (query.foo) {
    const foo: string = query.foo;
  }
});

history.push({
  pathname: '/',
  query: {
    foo: 'bar'
  }
});
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:19,代碼來源:qhistory-tests.ts

示例8: createBrowserHistory

import {createBrowserHistory} from "history";

export default createBrowserHistory();
開發者ID:langkilde,項目名稱:fatbat,代碼行數:3,代碼來源:historyCreator.ts

示例9: createBrowserHistory

import './css/site.css';
import 'bootstrap';
import * as ko from 'knockout';
import { createBrowserHistory } from 'history';
import './webpack-component-loader';
import AppRootComponent from './components/app-root/app-root';
const baseUrl = document.getElementsByTagName('base')[0].getAttribute('href')!;
const basename = baseUrl.substring(0, baseUrl.length - 1); // History component needs no trailing slash

// Load and register the <app-root> component
ko.components.register('app-root', AppRootComponent);

// Tell Knockout to start up an instance of your application
ko.applyBindings({ history: createBrowserHistory({ basename }), basename });

// Basic hot reloading support. Automatically reloads and restarts the Knockout app each time
// you modify source files. This will not preserve any application state other than the URL.
if (module.hot) {
    module.hot.accept();
    module.hot.dispose(() => ko.cleanNode(document.body));
}
開發者ID:juniwang,項目名稱:rasg,代碼行數:21,代碼來源:boot.ts

示例10: require

import {createStore, applyMiddleware, compose} from "redux";
const History = require("history");
import {routerMiddleware as create_redux_router_middleware} from "react-router-redux";
const thunk = require("redux-thunk").default;

import CONFIG from "../../../shared/config";
import {all_reducers} from "./reducers";
import {AppState} from "./shape";
import {Action} from "./actions";

// tslint:disable-next-line
// https://github.com/ReactTraining/react-router/tree/dc2149ec0c63bfc95b71e40c81431e34cfbfeda9/packages/react-router-redux
export const history = History.createBrowserHistory();
const redux_router_middleware = create_redux_router_middleware(history);
const redux_router_store_enhancer = applyMiddleware(thunk, redux_router_middleware);

// tslint:disable-next-line
const glo = (window || global) as any;
// From: https://github.com/zalmoxisus/redux-devtools-extension#1-with-redux
let compose_enhancers = compose;

if (CONFIG.ENV_DEVELOPMENT && glo.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) {
    compose_enhancers = glo.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({
        // Specify extension’s options like name, actionsBlacklist, actionsCreators, serialize...
    });
}

export const app_store = createStore<AppState>(
    all_reducers,
    compose_enhancers(redux_router_store_enhancer)
);
開發者ID:AJamesPhillips,項目名稱:napthr,代碼行數:31,代碼來源:store.ts


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