@@ -17,49 +17,50 @@ class Meta<T> {
17
17
18
18
/// Action that gets dispatched when an `AsyncThunk`
19
19
/// starts being processed.
20
- ///
20
+ ///
21
21
/// Will come with the `payload` passed to the thunk
22
22
/// within its `meta` member.
23
23
@immutable
24
- class Pending <T , M > extends PayloadAction <dynamic , Meta <M >, dynamic > {
24
+ class Pending <T , M > extends PayloadAction <void , Meta <M >, void > {
25
25
Pending (M meta, String requestId) : super (meta: Meta (meta, requestId));
26
26
}
27
27
28
28
/// Action that gets dispatched when an `AsyncThunk`
29
29
/// finishes successfully.
30
- ///
30
+ ///
31
31
/// Will have the `payload` that was initially passed
32
32
/// to the thunk within its `meta` and the result
33
33
/// of the operation in its `payload` .
34
34
@immutable
35
- class Fulfilled <T , P , M > extends PayloadAction <P , Meta <M >, dynamic > {
36
- Fulfilled (P payload, M meta, String requestId) : super (payload: payload, meta: Meta (meta, requestId));
35
+ class Fulfilled <T , P , M > extends PayloadAction <P , Meta <M >, void > {
36
+ Fulfilled (P payload, M meta, String requestId)
37
+ : super (payload: payload, meta: Meta (meta, requestId));
37
38
}
38
39
39
-
40
40
/// Action that gets dispatched when an `AsyncThunk`
41
41
/// finishes with an error.
42
- ///
42
+ ///
43
43
/// Will have the error that occurred in its `error`
44
44
/// member and within its `meta` you'll find the
45
45
/// `payload` that was initially passed to the thunk.
46
46
@immutable
47
- class Rejected <T , M , E > extends PayloadAction <dynamic , Meta <M >, E > {
48
- Rejected (M meta, E error, String requestId) : super (meta: Meta (meta, requestId), error: error);
47
+ class Rejected <T , M , E > extends PayloadAction <void , Meta <M >, E > {
48
+ Rejected (M meta, E error, String requestId)
49
+ : super (meta: Meta (meta, requestId), error: error);
49
50
}
50
51
51
52
/// Abstraction to make thunks that just deal with a `Future`
52
53
/// adhere to a standard.
53
- ///
54
+ ///
54
55
/// Before the `Future` starts processing this will dispatch a `Pending` action.
55
- ///
56
+ ///
56
57
/// After the `Future` resolves successfully this will dispatch a `Fulfilled` action.
57
- ///
58
+ ///
58
59
/// After the `Future` fails this will dispatch a `Rejected` action.
59
- ///
60
- ///
60
+ ///
61
+ ///
61
62
/// ### Example
62
- ///
63
+ ///
63
64
/// ```dart
64
65
/// @immutable
65
66
/// class FetchTodos extends AsyncThunk<FetchTodos, AppState, void, List<Todo>> {
@@ -72,9 +73,10 @@ class Rejected<T, M, E> extends PayloadAction<dynamic, Meta<M>, E> {
72
73
/// }
73
74
/// ```
74
75
@immutable
75
- abstract class AsyncThunk <Self , State , Payload , Result > implements CallableThunkAction <State > {
76
+ abstract class AsyncThunk <Self , State , Payload , Result >
77
+ implements CallableThunkAction <State > {
76
78
final Payload payload;
77
-
79
+
78
80
const AsyncThunk ([this .payload]);
79
81
80
82
Future <Result > run ();
0 commit comments