forked from redux-saga/redux-saga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.d.ts
111 lines (98 loc) · 4.2 KB
/
utils.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
import {
Pattern, ActionPattern, Effect,
TakeEffectDescriptor, ChannelTakeEffectDescriptor,
PutEffectDescriptor, ChannelPutEffectDescriptor,
AllEffectDescriptor, RaceEffectDescriptor,
CallEffectDescriptor, ForkEffectDescriptor,
JoinEffectDescriptor, CancelEffectDescriptor,
SelectEffectDescriptor, ActionChannelEffectDescriptor,
CancelledEffectDescriptor, FlushEffectDescriptor,
GetContextEffectDescriptor, SetContextEffectDescriptor,
} from "./effects";
import {Task, Channel, Buffer, SagaIterator} from "./index";
export function delay(ms: number): Promise<true>;
export function delay<T>(ms: number, val: T): Promise<T>;
export const TASK: string | symbol;
export const SAGA_ACTION: string | symbol;
export function noop(): void;
export type GuardPredicate<G extends T, T = any> = (arg: T) => arg is G;
export const is: {
undef: GuardPredicate<undefined>;
notUndef: GuardPredicate<any>;
func: GuardPredicate<Function>;
number: GuardPredicate<number>;
string: GuardPredicate<string>;
array: GuardPredicate<Array<any>>;
object: GuardPredicate<object>;
promise: GuardPredicate<Promise<any>>;
iterator: GuardPredicate<Iterator<any>>;
iterable: GuardPredicate<Iterable<any>>;
task: GuardPredicate<Task>;
observable: GuardPredicate<{subscribe: Function}>;
buffer: GuardPredicate<Buffer<any>>;
pattern: GuardPredicate<Pattern<any> | ActionPattern>;
channel: GuardPredicate<Channel<any>>;
helper: GuardPredicate<SagaIterator>;
stringableFunc: GuardPredicate<Function>;
};
interface Deferred<R> {
resolve(result: R): void;
reject(error: any): void;
promise: Promise<R>;
}
export function deferred<T, R>(props?: T): T & Deferred<R>;
export function arrayOfDeferred<T>(length: number): Deferred<T>[];
interface MockTask extends Task {
setRunning(running: boolean): void;
setResult(result: any): void;
setError(error: any): void;
}
export function createMockTask(): MockTask;
export const asEffect: {
take(effect: Effect):
undefined | TakeEffectDescriptor | ChannelTakeEffectDescriptor<any>;
put(effect: Effect):
undefined | PutEffectDescriptor<any> | ChannelPutEffectDescriptor<any>;
all(effect: Effect): undefined | AllEffectDescriptor;
race(effect: Effect): undefined | RaceEffectDescriptor;
call(effect: Effect): undefined | CallEffectDescriptor;
cps(effect: Effect): undefined | CallEffectDescriptor;
fork(effect: Effect): undefined | ForkEffectDescriptor;
join(effect: Effect): undefined | JoinEffectDescriptor;
cancel(effect: Effect): undefined | CancelEffectDescriptor;
select(effect: Effect): undefined | SelectEffectDescriptor;
actionChannel(effect: Effect): undefined | ActionChannelEffectDescriptor;
cancelled(effect: Effect): undefined | CancelledEffectDescriptor;
flush(effect: Effect): undefined | FlushEffectDescriptor<any>;
getContext(effect: Effect): undefined | GetContextEffectDescriptor;
setContext(effect: Effect): undefined | SetContextEffectDescriptor<any>;
};
interface SagaIteratorClone extends SagaIterator {
clone: () => SagaIteratorClone;
}
export function cloneableGenerator(
iterator: () => SagaIterator
): () => SagaIteratorClone;
export function cloneableGenerator<T1>(
iterator: (arg1: T1) => SagaIterator
): (arg1: T1) => SagaIteratorClone;
export function cloneableGenerator<T1, T2>(
iterator: (arg1: T1, arg2: T2) => SagaIterator
): (arg1: T1, arg2: T2) => SagaIteratorClone;
export function cloneableGenerator<T1, T2, T3>(
iterator: (arg1: T1, arg2: T2, arg3: T3) => SagaIterator
): (arg1: T1, arg2: T2, arg3: T3) => SagaIteratorClone;
export function cloneableGenerator<T1, T2, T3, T4>(
iterator: (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => SagaIterator
): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => SagaIteratorClone;
export function cloneableGenerator<T1, T2, T3, T4, T5>(
iterator: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => SagaIterator
): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => SagaIteratorClone;
export function cloneableGenerator<T1, T2, T3, T4, T5, T6>(
iterator: (arg1: T1, arg2: T2, arg3: T3,
arg4: T4, arg5: T5, arg6: T6,
arg7: any, ...rest: any[]) => SagaIterator
): (arg1: T1, arg2: T2, arg3: T3,
arg4: T4, arg5: T5, arg6: T6,
...rest: any[]
) => SagaIteratorClone;