UNPKG

@gongt/ts-stl-client

Version:
43 lines 2 kB
"use strict"; ///<reference types="node"/> Object.defineProperty(exports, "__esModule", { value: true }); const history_object_1 = require("@gongt/ts-stl-library/browser/history-object"); const global_page_data_1 = require("@gongt/ts-stl-library/pattern/global-page-data"); const react_router_redux_1 = require("react-router-redux"); const client_1 = require("../../react-redux/client"); const redux_router_store_1 = require("./redux-router.store"); if (!react_router_redux_1.ConnectedRouter) { throw new TypeError('package `react-router-redux` not export ConnectedRouter, have you installed @next version?'); } function reduxHandleReactRouter(react, redux, options = {}) { reduxHandleReactRouterBase(react, redux, () => { return options; }); client_1.reactUseRedux(react); } exports.reduxHandleReactRouter = reduxHandleReactRouter; function reduxHandleReactRouterBase(react, redux, options) { const preventDuplicate = new global_page_data_1.GlobalVariable(react); if (preventDuplicate.has('reduxRouter')) { throw new TypeError('reduxHandleReactRouter(): duplicate call.'); } if (preventDuplicate.has('router')) { throw new TypeError('reduxHandleReactRouter(): must not call reactUseRouter().'); } if (preventDuplicate.has('redux')) { throw new TypeError('reduxHandleReactRouter(): must not call reactUseRedux().'); } preventDuplicate.set('reduxRouter', true); react.wrapComponent('ConnectedRouter', react_router_redux_1.ConnectedRouter, (global) => { let history = history_object_1.createSingletonHistory(global, options(global)); return { history, }; }); redux.useDynamic((global) => { return react_router_redux_1.routerMiddleware(history_object_1.createSingletonHistory(global, options(global))); }); redux.register(redux_router_store_1.routing); } exports.reduxHandleReactRouterBase = reduxHandleReactRouterBase; //# sourceMappingURL=redux-router.js.map