saga-toolkit 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +63 -38
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -1,50 +1,75 @@
|
|
|
1
|
-
|
|
1
|
+
import { createAsyncThunk, ThunkAction, SerializedError, Action } from '@reduxjs/toolkit';
|
|
2
|
+
import { ForkEffect, PutEffect, TakeEffect, Saga, CallEffect, ForkEffectDescriptor } from '@redux-saga/core/effects';
|
|
3
|
+
import { Deferred } from '@redux-saga/deferred';
|
|
2
4
|
|
|
3
5
|
declare module 'saga-toolkit' {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { SagaIterator } from 'redux-saga'
|
|
7
|
-
import { ActionCreatorWithPayload } from '@reduxjs/toolkit/src/createAction'
|
|
8
|
-
import { AsyncThunkFulfilledActionCreator, AsyncThunkConfig } from '@reduxjs/toolkit/src/createAsyncThunk'
|
|
9
|
-
|
|
10
|
-
type AsyncSagaPayloadCreator<Returned, ThunkArg = void> = (
|
|
11
|
-
arg: ThunkArg,
|
|
12
|
-
requestId: string
|
|
13
|
-
) => Promise<Returned>
|
|
14
|
-
|
|
15
|
-
type AsyncSagaActionCreator<
|
|
16
|
-
Returned,
|
|
17
|
-
ThunkArg,
|
|
18
|
-
ThunkApiConfig extends AsyncThunkConfig = {}
|
|
19
|
-
> = (
|
|
20
|
-
arg: ThunkArg
|
|
21
|
-
) => ActionCreatorWithPayload<
|
|
22
|
-
Promise<Returned>,
|
|
23
|
-
ReturnType<Dispatch>,
|
|
6
|
+
type SagaAction<Arg, ReturnType> = ThunkAction<
|
|
7
|
+
Promise<ReturnType<Arg>>,
|
|
24
8
|
unknown,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
9
|
+
{ requestId: string },
|
|
10
|
+
Action<string>
|
|
11
|
+
> & {
|
|
12
|
+
type: string;
|
|
13
|
+
requestId: string;
|
|
14
|
+
abort: () => void;
|
|
15
|
+
then: (onfulfilled?: (value: SagaActionResult<Arg, ReturnType>) => void) => Promise<SagaActionResult<Arg, ReturnType>>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
interface IRequest {
|
|
19
|
+
requestId: string;
|
|
20
|
+
deferred: Deferred<any>;
|
|
21
|
+
onAdd?: (request: IRequest) => void;
|
|
22
|
+
abort?: () => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type SagaActionResult<Arg, ReturnType> = {
|
|
26
|
+
payload: ReturnType;
|
|
27
|
+
meta: {
|
|
28
|
+
requestId: string;
|
|
29
|
+
arg: Arg;
|
|
30
|
+
};
|
|
31
|
+
error?: SerializedError;
|
|
34
32
|
}
|
|
35
33
|
|
|
36
|
-
export function createSagaAction<
|
|
34
|
+
export function createSagaAction<PayloadType, ReturnType = void>(
|
|
37
35
|
type: string
|
|
38
|
-
):
|
|
36
|
+
): {
|
|
37
|
+
(payload: PayloadType): SagaAction<PayloadType, ReturnType>;
|
|
39
38
|
pending: string;
|
|
40
|
-
fulfilled: string;
|
|
41
39
|
rejected: string;
|
|
40
|
+
fulfilled: string;
|
|
42
41
|
typePrefix: string;
|
|
43
42
|
type: string;
|
|
44
|
-
}
|
|
43
|
+
};
|
|
45
44
|
|
|
46
|
-
export function
|
|
47
|
-
|
|
48
|
-
export function
|
|
49
|
-
|
|
45
|
+
export function* getRequest(requestId: string): Generator<CallEffect, IRequest, any>;
|
|
46
|
+
|
|
47
|
+
export function takeEveryAsync<ActionPattern extends string>(
|
|
48
|
+
pattern: ActionPattern,
|
|
49
|
+
saga: Saga<[], void>,
|
|
50
|
+
...args: any[]
|
|
51
|
+
): ForkEffect<void>;
|
|
52
|
+
|
|
53
|
+
export function takeLatestAsync<ActionPattern extends string>(
|
|
54
|
+
pattern: ActionPattern,
|
|
55
|
+
saga: Saga<[], void>,
|
|
56
|
+
...args: any[]
|
|
57
|
+
): ForkEffect<void>;
|
|
58
|
+
|
|
59
|
+
export function takeAggregateAsync<ActionPattern extends string>(
|
|
60
|
+
pattern: ActionPattern,
|
|
61
|
+
saga: Saga<[], void>,
|
|
62
|
+
...args: any[]
|
|
63
|
+
): ForkEffect<void>;
|
|
64
|
+
|
|
65
|
+
export function* putAsync<T>(
|
|
66
|
+
action: SagaAction<T>
|
|
67
|
+
): Generator<PutEffect<SagaAction<T>>, any, any>;
|
|
68
|
+
|
|
69
|
+
export type SagaActionFromCreator<Creator extends (...args: any) => any> = SagaActionResult<
|
|
70
|
+
Parameters<Creator>[0],
|
|
71
|
+
void
|
|
72
|
+
> & {
|
|
73
|
+
action: string
|
|
74
|
+
}
|
|
50
75
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "saga-toolkit",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "An extension for redux-toolkit that allows sagas to resolve async thunk actions.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@babel/core": "^7.16.12",
|
|
31
31
|
"@babel/node": "^7.16.8",
|
|
32
32
|
"@babel/preset-env": "^7.16.11",
|
|
33
|
-
"@reduxjs/toolkit": "^1.
|
|
33
|
+
"@reduxjs/toolkit": "^1.9.5",
|
|
34
34
|
"redux": "^4.1.2"
|
|
35
35
|
}
|
|
36
36
|
}
|