This repository was archived by the owner on Dec 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.d.ts
More file actions
123 lines (104 loc) · 2.61 KB
/
index.d.ts
File metadata and controls
123 lines (104 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import {
Reducer,
Action,
AnyAction,
ReducersMapObject,
MiddlewareAPI,
StoreEnhancer,
bindActionCreators,
} from "redux";
import { History } from "history";
export interface Dispatch<A extends Action = AnyAction> {
<T extends A>(action: T): Promise<any> | T;
}
export interface onActionFunc {
(api: MiddlewareAPI<any>): void;
}
export interface ReducerEnhancer {
(reducer: Reducer<any>): void;
}
export interface Hooks {
onError?: (e: Error, dispatch: Dispatch<any>) => void;
onAction?: onActionFunc | onActionFunc[];
onStateChange?: () => void;
onReducer?: ReducerEnhancer;
onEffect?: () => void;
onHmr?: () => void;
extraReducers?: ReducersMapObject;
extraEnhancers?: StoreEnhancer<any>[];
}
export type DvaOption = Hooks & {
namespacePrefixWarning?: boolean;
initialState?: Object;
history?: Object;
};
export interface EffectsCommandMap {
put: <A extends AnyAction>(action: A) => any;
call: Function;
select: Function;
take: Function;
cancel: Function;
[key: string]: any;
}
export type Effect = (action: AnyAction, effects: EffectsCommandMap) => void;
export type EffectType = "takeEvery" | "takeLatest" | "watcher" | "throttle";
export type EffectWithType = [Effect, { type: EffectType }];
export type Subscription = (api: SubscriptionAPI, done: Function) => void;
export type ReducersMapObjectWithEnhancer = [
ReducersMapObject,
ReducerEnhancer
];
export interface EffectsMapObject {
[key: string]: Effect | EffectWithType;
}
export interface SubscriptionAPI {
history: History;
dispatch: Dispatch<any>;
}
export interface SubscriptionsMapObject {
[key: string]: Subscription;
}
export interface Model {
namespace: string;
state?: any;
reducers?: ReducersMapObject | ReducersMapObjectWithEnhancer;
effects?: EffectsMapObject;
subscriptions?: SubscriptionsMapObject;
}
export interface DvaInstance {
/**
* Register an object of hooks on the application.
*
* @param hooks
*/
use: (hooks: Hooks) => void;
/**
* Register a model.
*
* @param model
*/
model: (model: Model) => void;
/**
* Unregister a model.
*
* @param namespace
*/
unmodel: (namespace: string) => void;
/**
* Start the application. Selector is optional. If no selector
* arguments, it will return a function that return JSX elements.
*
* @param selector
*/
start: (selector?: React.ReactNode, opts?: { forwardRef: boolean }) => any;
}
export default function dva(opts?: DvaOption): DvaInstance;
export { bindActionCreators };
export {
connect,
connectAdvanced,
useSelector,
useDispatch,
useStore,
shallowEqual,
} from "react-redux";