UNPKG

2 kBJavaScriptView Raw
1"use strict";
2///<reference types="node"/>
3Object.defineProperty(exports, "__esModule", { value: true });
4const history_object_1 = require("@gongt/ts-stl-library/browser/history-object");
5const global_page_data_1 = require("@gongt/ts-stl-library/pattern/global-page-data");
6const react_router_redux_1 = require("react-router-redux");
7const client_1 = require("../../react-redux/client");
8const redux_router_store_1 = require("./redux-router.store");
9if (!react_router_redux_1.ConnectedRouter) {
10 throw new TypeError('package `react-router-redux` not export ConnectedRouter, have you installed @next version?');
11}
12function reduxHandleReactRouter(react, redux, options = {}) {
13 reduxHandleReactRouterBase(react, redux, () => {
14 return options;
15 });
16 client_1.reactUseRedux(react);
17}
18exports.reduxHandleReactRouter = reduxHandleReactRouter;
19function reduxHandleReactRouterBase(react, redux, options) {
20 const preventDuplicate = new global_page_data_1.GlobalVariable(react);
21 if (preventDuplicate.has('reduxRouter')) {
22 throw new TypeError('reduxHandleReactRouter(): duplicate call.');
23 }
24 if (preventDuplicate.has('router')) {
25 throw new TypeError('reduxHandleReactRouter(): must not call reactUseRouter().');
26 }
27 if (preventDuplicate.has('redux')) {
28 throw new TypeError('reduxHandleReactRouter(): must not call reactUseRedux().');
29 }
30 preventDuplicate.set('reduxRouter', true);
31 react.wrapComponent('ConnectedRouter', react_router_redux_1.ConnectedRouter, (global) => {
32 let history = history_object_1.createSingletonHistory(global, options(global));
33 return {
34 history,
35 };
36 });
37 redux.useDynamic((global) => {
38 return react_router_redux_1.routerMiddleware(history_object_1.createSingletonHistory(global, options(global)));
39 });
40 redux.register(redux_router_store_1.routing);
41}
42exports.reduxHandleReactRouterBase = reduxHandleReactRouterBase;
43//# sourceMappingURL=redux-router.js.map
\No newline at end of file