forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redux-saga.d.ts
141 lines (99 loc) · 4.37 KB
/
redux-saga.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
// Type definitions for redux-saga 0.9.1
// Project: https://github.com/yelouafi/redux-saga
// Definitions by: Daniel Lytkin <https://github.com/aikoven>, Dimitri Rosenberg <https://github.com/rosendi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../redux/redux.d.ts" />
declare module 'redux-saga' {
export class SagaCancellationException {
}
export type Saga = <T>(getState?: () => T) => Iterable<any>;
export type Predicate = (action: any) => boolean;
export type Pattern = string | string[] | Predicate;
import {Middleware} from 'redux';
interface SagaMiddleware extends Middleware {
run(saga: Saga, ...args: any[]): void;
}
export default function (...sagas: Saga[]): SagaMiddleware;
export {
CANCEL,
RACE_AUTO_CANCEL,
PARALLEL_AUTO_CANCEL,
MANUAL_CANCEL
} from 'redux-saga/lib/proc';
import * as monitorActions from 'redux-saga/lib/monitorActions';
export {monitorActions}
export {runSaga, storeIO} from 'redux-saga/lib/runSaga'
export interface Task<T> {
name:string;
isRunning():boolean;
result():T;
error():any;
cancel(): void;
}
export function takeEvery(pattern: Pattern, saga: Saga, ...args: any[]): { [Symbol.iterator](): IterableIterator<any> };
export function takeLatest(pattern: Pattern, saga: Saga, ...args: any[]): { [Symbol.iterator](): IterableIterator<any> };
export function delay(ms: number): Promise<boolean>;
export function delay<T>(ms: number, val: T): Promise<T>;
export function isCancelError(e: any): boolean;
}
declare module 'redux-saga/effects' {
import {Task} from 'redux-saga';
import {Predicate} from 'redux-saga';
import {Pattern} from 'redux-saga';
export type Effect = {};
type EffectFunction<T1, T2, T3> = (arg1?: T1, arg2?: T2, arg3?: T3, ...rest: any[]) => Promise<any> | Iterable<any>;
interface EffectFunctionContext<T1, T2, T3> {
0: any;
1: EffectFunction<T1, T2, T3>;
}
export function take(pattern?: Pattern): Effect;
export function put(action: any): Effect;
export function race(effects: {[key:string]: any}): Effect;
export function call<T1, T2, T3>(fn: EffectFunction<T1, T2, T3>, arg1?: T1, arg2?: T2, arg3?: T3, ...rest: any[]): Effect;
export function call<T1, T2, T3>(fn: EffectFunctionContext<T1, T2, T3>, arg1?: T1, arg2?: T2, arg3?: T3, ...rest: any[]): Effect;
export function apply<T1, T2, T3>(context: any, fn: EffectFunction<T1, T2, T3>, arg1?: T1, arg2?: T2, arg3?: T3, ...rest: any[]): Effect;
export function fork(effect: Effect): Effect;
export function fork<T1, T2, T3>(fn: EffectFunction<T1, T2, T3>, arg1?: T1, arg2?: T2, arg3?: T3, ...rest: any[]): Effect;
export function fork<T1, T2, T3>(fn: EffectFunctionContext<T1, T2, T3>, arg1?: T1, arg2?: T2, arg3?: T3, ...rest: any[]): Effect;
export function join(task: Task<any>): Effect;
export function select(selector?: (state: any, ...args: any[]) => any, ...args: any[]): Effect;
export function cancel(task: Task<any>): Effect;
}
declare module 'redux-saga/lib/proc' {
import {Task} from 'redux-saga';
export const CANCEL: symbol;
export const NOT_ITERATOR_ERROR: string;
export const PARALLEL_AUTO_CANCEL: string;
export const RACE_AUTO_CANCEL: string;
export const MANUAL_CANCEL: string;
export default function proc(iterator: Iterable<any>,
subscribe?: (cb: Function) => Function,
dispatch?: (action: any) => any,
monitor?: (action: any) => void,
parentEffectId?: any,
name?: string): Task<any>;
}
declare module 'redux-saga/lib/runSaga' {
import {Store} from 'redux';
import {Task} from 'redux-saga';
interface IO {
dispatch: (action: any) => any;
subscribe: (cb: Function) => Function;
}
export function storeIO(store: Store): IO;
export function runSaga(iterator: Iterable<any>,
io: IO,
monitor?: (action: any) => void): Task<any>;
}
declare module 'redux-saga/lib/emitter' {
export default function emitter(): {
subscribe(cb: Function):Function;
emit(item: any):void;
}
}
declare module 'redux-saga/lib/monitorActions' {
export const MONITOR_ACTION: string;
export const EFFECT_TRIGGERED: string;
export const EFFECT_RESOLVED: string;
export const EFFECT_REJECTED: string;
}