From 0560e36eb12ac39cfe9b6d1c866758832ca36c0c Mon Sep 17 00:00:00 2001 From: Isman Usoh Date: Wed, 24 Feb 2016 09:10:54 +0700 Subject: [PATCH] duplicate for legacy version (2.x-3.x) --- .../react-router-redux-2.x-tests.ts | 20 ++++++++ .../react-router-redux-2.x.d.ts | 48 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 react-router-redux/react-router-redux-2.x-tests.ts create mode 100644 react-router-redux/react-router-redux-2.x.d.ts diff --git a/react-router-redux/react-router-redux-2.x-tests.ts b/react-router-redux/react-router-redux-2.x-tests.ts new file mode 100644 index 000000000..9b3d59fbb --- /dev/null +++ b/react-router-redux/react-router-redux-2.x-tests.ts @@ -0,0 +1,20 @@ +/// +/// +/// + + + +import { createStore, combineReducers, applyMiddleware } from 'redux'; +import { browserHistory } from 'react-router'; +import { syncHistory, routeReducer } from 'react-router-redux'; + +const reducer = combineReducers({ routing: routeReducer }); + +// Sync dispatched route actions to the history +const reduxRouterMiddleware = syncHistory(browserHistory); +const createStoreWithMiddleware = applyMiddleware(reduxRouterMiddleware)(createStore); + +const store = createStoreWithMiddleware(reducer); + +// Required for replaying actions from devtools to +reduxRouterMiddleware.listenForReplays(store); diff --git a/react-router-redux/react-router-redux-2.x.d.ts b/react-router-redux/react-router-redux-2.x.d.ts new file mode 100644 index 000000000..7248fb3af --- /dev/null +++ b/react-router-redux/react-router-redux-2.x.d.ts @@ -0,0 +1,48 @@ +// Type definitions for react-router-redux v2.1.0 +// Project: https://github.com/rackt/react-router-redux +// Definitions by: Isman Usoh , Noah Shipley , Dimitri Rosenberg +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare namespace ReactRouterRedux { + import R = Redux; + import H = HistoryModule; + + const TRANSITION: string; + const UPDATE_LOCATION: string; + + const push: PushAction; + const replace: ReplaceAction; + const go: GoAction; + const goBack: GoForwardAction; + const goForward: GoBackAction; + const routeActions: RouteActions; + + type LocationDescriptor = H.Location | H.Path; + type PushAction = (nextLocation: LocationDescriptor) => void; + type ReplaceAction = (nextLocation: LocationDescriptor) => void; + type GoAction = (n: number) => void; + type GoForwardAction = () => void; + type GoBackAction = () => void; + + interface RouteActions { + push: PushAction; + replace: ReplaceAction; + go: GoAction; + goForward: GoForwardAction; + goBack: GoBackAction; + } + interface HistoryMiddleware extends R.Middleware { + listenForReplays(store: R.Store, selectLocationState?: Function): void; + unsubscribe(): void; + } + + function routeReducer(state?: any, options?: any): R.Reducer; + function syncHistory(history: H.History): HistoryMiddleware; +} + +declare module "react-router-redux" { + export = ReactRouterRedux; +}