forked from redux-saga/redux-saga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheffects.d.ts
193 lines (141 loc) · 5.48 KB
/
effects.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import {Channel, Task, Buffer, Predicate} from "./types";
type Pattern<T> = string | string[] | Predicate<T>;
interface TakeEffectDescriptor<T> {
pattern: Pattern<T>;
channel: Channel<T>;
maybe?: boolean;
}
interface TakeEffect<T> {
TAKE: TakeEffectDescriptor<T>;
}
export function take<T>(pattern: Pattern<T>): TakeEffect<T>;
export function take<T>(channel: Channel<T>,
pattern?: Pattern<T>): TakeEffect<T>;
export function takem<T>(pattern: Pattern<T>): TakeEffect<T>;
export function takem<T>(channel: Channel<T>,
pattern?: Pattern<T>): TakeEffect<T>;
interface PutEffectDescriptor<T> {
action: T;
channel: Channel<T>;
}
interface PutEffect<T> {
PUT: PutEffectDescriptor<T>;
}
export function put<T>(action: T): PutEffect<T>;
export function put<T>(channel: Channel<T>, action: T): PutEffect<T>;
type RaceEffectDescriptor = {[key: string]: Effect};
interface RaceEffect {
RACE: RaceEffectDescriptor;
}
export function race(effects: {[key: string]: Effect}): RaceEffect;
interface CallEffectDescriptor {
context: any;
fn: Function;
args: any[];
}
type CallFunc0 = () => any;
type CallFunc1<T1> = (arg1: T1) => any;
type CallFunc2<T1, T2> = (arg1: T1, arg2: T2) => any;
type CallFunc3<T1, T2, T3> = (arg1: T1, arg2: T2, arg3: T3) => any;
type CallFunc4<T1, T2, T3, T4> = (arg1: T1, arg2: T2, arg3: T3,
arg4: T4) => any;
type CallFunc5<T1, T2, T3, T4, T5> = (arg1: T1, arg2: T2, arg3: T3,
arg4: T4, arg5: T5) => any;
type CallFuncRest = (...args: any[]) => any;
type CallEffectArg<F> = F | [any, F] | {context: any, fn: F};
interface CallEffectFactory<R> {
(fn: CallEffectArg<CallFunc0>): R;
<T1>(fn: CallEffectArg<CallFunc1<T1>>,
arg1: T1): R;
<T1, T2>(fn: CallEffectArg<CallFunc2<T1, T2>>,
arg1: T1, arg2: T2): R;
<T1, T2, T3>(fn: CallEffectArg<CallFunc3<T1, T2, T3>>,
arg1: T1, arg2: T2, arg3: T3): R;
<T1, T2, T3, T4>(fn: CallEffectArg<CallFunc4<T1, T2, T3, T4>>,
arg1: T1, arg2: T2, arg3: T3, arg4: T4): R;
(fn: CallEffectArg<CallFuncRest>, ...args: any[]): R;
}
interface CallEffect {
CALL: CallEffectDescriptor;
}
export const call: CallEffectFactory<CallEffect>;
export function apply(context: any, fn: CallFunc0): CallEffect;
export function apply<T1>(context: any, fn: CallFunc1<T1>,
args: [T1]): CallEffect;
export function apply<T1, T2>(context: any, fn: CallFunc2<T1, T2>,
args: [T1, T2]): CallEffect;
export function apply<T1, T2, T3>(context: any, fn: CallFunc3<T1, T2, T3>,
args: [T1, T2, T3]): CallEffect;
export function apply<T1, T2, T3, T4>(context: any,
fn: CallFunc4<T1, T2, T3, T4>,
args: [T1, T2, T3, T4]): CallEffect;
export function apply(context: any, fn: CallFuncRest,
...args: any[]): CallEffect;
interface CpsEffect {
CPS: CallEffectDescriptor;
}
type CpsCallback = (error: any, result: any) => void;
export function cps(fn: CallEffectArg<CallFunc1<CpsCallback>>): CpsEffect;
export function cps<T1>(fn: CallEffectArg<CallFunc2<T1, CpsCallback>>,
arg1: T1): CpsEffect;
export function cps<T1, T2>(fn: CallEffectArg<CallFunc3<T1, T2, CpsCallback>>,
arg1: T1, arg2: T2): CpsEffect;
export function cps<T1, T2, T3>(
fn: CallEffectArg<CallFunc4<T1, T2, T3, CpsCallback>>,
arg1: T1, arg2: T2, arg3: T3): CpsEffect;
export function cps<T1, T2, T3, T4>(
fn: CallEffectArg<CallFunc5<T1, T2, T3, T4, CpsCallback>>,
arg1: T1, arg2: T2, arg3: T3, arg4: T4): CpsEffect;
interface ForkEffectDescriptor extends CallEffectDescriptor {
detached?: boolean;
}
interface ForkEffect {
FORK: ForkEffectDescriptor;
}
export const fork: CallEffectFactory<ForkEffect>;
export const spawn: CallEffectFactory<ForkEffect>;
interface JoinEffect {
JOIN: Task;
}
export function join(task: Task): JoinEffect;
interface CancelEffect {
CANCEL: Task;
}
export function cancel(task: Task): CancelEffect;
interface SelectEffectDescriptor {
selector(state: any, ...args: any[]): any;
args: any[];
}
interface SelectEffect {
SELECT: SelectEffectDescriptor;
}
export function select(): SelectEffect;
export function select<S>(selector: CallFunc1<S>): SelectEffect;
export function select<S, T1>(selector: CallFunc2<S, T1>,
arg1: T1): SelectEffect;
export function select<S, T1, T2>(selector: CallFunc3<S, T1, T2>,
arg1: T1, arg2: T2): SelectEffect;
export function select<S, T1, T2, T3>(selector: CallFunc4<S, T1, T2, T3>,
arg1: T1, arg2: T2, arg3: T3): SelectEffect;
export function select<S, T1, T2, T3, T4>(
selector: CallFunc5<S, T1, T2, T3, T4>,
arg1: T1, arg2: T2, arg3: T3, arg4: T4): SelectEffect;
interface ActionChannelEffectDescriptor<T> {
pattern: Pattern<T>;
buffer: Buffer<T>;
}
interface ActionChannelEffect<T> {
ACTION_CHANNEL: ActionChannelEffectDescriptor<T>;
}
export function actionChannel<T>(pattern: Pattern<T>,
buffer?: Buffer<T>): ActionChannelEffect<T>;
interface CancelledEffect {
CANCELLED: {};
}
export function cancelled(): CancelledEffect;
export type Effect =
TakeEffect<any> |
PutEffect<any> |
RaceEffect | CallEffect |
CpsEffect | ForkEffect | JoinEffect | CancelEffect | SelectEffect |
ActionChannelEffect<any> | CancelledEffect;