-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js.flow
51 lines (45 loc) · 1.26 KB
/
index.js.flow
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
/* @flow */
export type Action<T> = {
type: string,
payload: T
}
export type ActionCreator<Input, Payload = Input> = {
(Input): Action<Payload>,
type: string
}
export type Reducer<State> = {
(State, Action<*>): State,
get: () => Reducer<State>,
case<Input, Payload>(
ActionCreator<Input, Payload> | string,
(State, Payload) => State
): Reducer<State>,
else((State, Action<*>) => State): Reducer<State>
}
declare module.exports: {
buildActionCreator: (
?{ prefix?: string }
) => {
createAction<Input, Payload>(
t?: string | void,
fn?: (Input) => Payload
): ActionCreator<Input, Payload>,
createAsyncAction<Input, Payload>(
t?: string | void,
fn: (Input) => Promise<Payload>
): {
started: ActionCreator<Input, void>,
resolved: ActionCreator<Input, Payload>,
rejected: ActionCreator<Input, Error>
} & (Input => Promise<Payload>),
createThunkAction<Input, A: any, S: any, R: any>(
t: string | void,
fn: (Input, dispatch: (a: A) => any, getState: () => S) => Promise<R>
): {
started: ActionCreator<Input, void>,
resolved: ActionCreator<Input, R>,
rejected: ActionCreator<Input, Error>
} & (Input => void)
},
createReducer: <T>(T) => Reducer<T>
}