-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
36 lines (28 loc) · 1.14 KB
/
index.d.ts
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
import { Action, ActionFunctionAny, Reducer } from 'redux-actions'
declare module 'redux-promise-utils' {
export type AsyncActionFunctionAny<R, P, Arguments = {}> = (args?: Arguments) => Promise<P>
export function createPromiseAction<Payload, Arguments>(
type: string,
asyncFunc: (args?: Arguments) => Promise<Payload>
): AsyncActionFunctionAny<Action<Payload>, Payload, Arguments>
interface IHandlerOptions<State> {
start?: (state: State, action: Action<any>) => State,
success?: (state: State, action: Action<any>) => State,
fail?: (state: State, action: Action<any>) => State,
}
interface IReducer<State, Payload> {
// handle sync Action
which(
type: ActionFunctionAny<Action<any>>,
handler: (state: State, action: Action<any>) => State
): IReducer<State, Payload>
// handle async Action
asyncWhich(
type: AsyncActionFunctionAny<Action<Payload>, Payload>,
options: IHandlerOptions<State>
): IReducer<State, Payload>
// build reducer
build: () => Reducer<State, Payload>
}
export function createReducer<State, Payload>(initState: State): IReducer<State, Payload>
}