1 | export interface AnyAction {
|
2 | type: any;
|
3 | }
|
4 | export declare type Meta = null | {
|
5 | [key: string]: any;
|
6 | };
|
7 | export interface Action<Payload> extends AnyAction {
|
8 | type: string;
|
9 | payload: Payload;
|
10 | error?: boolean;
|
11 | meta?: Meta;
|
12 | }
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | export declare function isType<Payload>(action: AnyAction, actionCreator: ActionCreator<Payload>): action is Action<Payload>;
|
28 | export interface ActionCreator<Payload> {
|
29 | type: string;
|
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 | match: (action: AnyAction) => action is Action<Payload>;
|
57 | |
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 | (payload: Payload, meta?: Meta): Action<Payload>;
|
64 | }
|
65 | export declare type Success<Params, Result> = ({
|
66 | params: Params;
|
67 | } | (Params extends void ? {
|
68 | params?: Params;
|
69 | } : never)) & ({
|
70 | result: Result;
|
71 | } | (Result extends void ? {
|
72 | result?: Result;
|
73 | } : never));
|
74 | export declare type Failure<Params, Error> = ({
|
75 | params: Params;
|
76 | } | (Params extends void ? {
|
77 | params?: Params;
|
78 | } : never)) & {
|
79 | error: Error;
|
80 | };
|
81 | export interface AsyncActionCreators<Params, Result, Error = {}> {
|
82 | type: string;
|
83 | started: ActionCreator<Params>;
|
84 | done: ActionCreator<Success<Params, Result>>;
|
85 | failed: ActionCreator<Failure<Params, Error>>;
|
86 | }
|
87 | export interface ActionCreatorFactory {
|
88 | |
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 | <Payload = void>(type: string, commonMeta?: Meta, isError?: boolean): ActionCreator<Payload>;
|
97 | |
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 | <Payload = void>(type: string, commonMeta?: Meta, isError?: (payload: Payload) => boolean): ActionCreator<Payload>;
|
107 | /**
|
108 | * Creates three Action Creators:
|
109 | * * `started: ActionCreator<Params>`
|
110 | * * `done: ActionCreator<{params: Params, result: Result}>`
|
111 | * * `failed: ActionCreator<{params: Params, error: Error}>`
|
112 | *
|
113 | * Useful to wrap asynchronous processes.
|
114 | *
|
115 | * @param type Prefix for types of created actions, which will have types
|
116 | * `${type}_STARTED`, `${type}_DONE` and `${type}_FAILED`.
|
117 | * @param commonMeta Metadata added to created actions.
|
118 | */
|
119 | async<Params, Result, Error = {}>(type: string, commonMeta?: Meta): AsyncActionCreators<Params, Result, Error>;
|
120 | }
|
121 | /**
|
122 | * Creates Action Creator factory with optional prefix for action types.
|
123 | * @param prefix Prefix to be prepended to action types as `<prefix>/<type>`.
|
124 | * @param defaultIsError Function that detects whether action is error given the
|
125 | * payload. Default is `payload => payload instanceof Error`.
|
126 | */
|
127 | export declare function actionCreatorFactory(prefix?: string | null, defaultIsError?: (payload: any) => boolean): ActionCreatorFactory;
|
128 | export default actionCreatorFactory;
|
129 |
|
\ | No newline at end of file |