1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | import {
|
10 | Store,
|
11 | Dispatch,
|
12 | Middleware,
|
13 | Reducer
|
14 | } from 'redux';
|
15 | import {
|
16 | History,
|
17 | Location,
|
18 | Path,
|
19 | LocationState,
|
20 | LocationDescriptor
|
21 | } from 'history';
|
22 | import * as React from 'react';
|
23 | import { match } from 'react-router';
|
24 |
|
25 | export interface ConnectedRouterProps<State> {
|
26 | children?: React.ReactNode;
|
27 | store?: Store<State> | undefined;
|
28 | history: History;
|
29 | }
|
30 | export class ConnectedRouter<State> extends React.Component<ConnectedRouterProps<State>> {}
|
31 |
|
32 | export const LOCATION_CHANGE = '@@router/LOCATION_CHANGE';
|
33 |
|
34 | export interface RouterState {
|
35 | location: Location | null;
|
36 | }
|
37 |
|
38 | export const routerReducer: Reducer<RouterState>;
|
39 |
|
40 | export const CALL_HISTORY_METHOD = '@@router/CALL_HISTORY_METHOD';
|
41 |
|
42 | export function push(location: LocationDescriptor, state?: LocationState): RouterAction;
|
43 | export function replace(location: LocationDescriptor, state?: LocationState): RouterAction;
|
44 | export function go(n: number): RouterAction;
|
45 | export function goBack(): RouterAction;
|
46 | export function goForward(): RouterAction;
|
47 |
|
48 | export const routerActions: {
|
49 | push: typeof push
|
50 | replace: typeof replace
|
51 | go: typeof go
|
52 | goBack: typeof goBack
|
53 | goForward: typeof goForward
|
54 | };
|
55 |
|
56 | export interface LocationActionPayload {
|
57 | method: string;
|
58 | args?: any[] | undefined;
|
59 | }
|
60 |
|
61 | export interface RouterAction {
|
62 | type: typeof CALL_HISTORY_METHOD;
|
63 | payload: LocationActionPayload;
|
64 | }
|
65 |
|
66 | export interface LocationChangeAction {
|
67 | type: typeof LOCATION_CHANGE;
|
68 | payload: Location & {
|
69 | props?: {
|
70 | match: {
|
71 | path: string;
|
72 | url: string;
|
73 | params: any;
|
74 | isExact: boolean;
|
75 | },
|
76 | location: Location;
|
77 | history: History;
|
78 | } | undefined
|
79 | };
|
80 | }
|
81 |
|
82 | export function routerMiddleware(history: History): Middleware;
|
83 |
|
84 | export function createMatchSelector(path: string): (state: { router: RouterState }) => match | null;
|