forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rx.experimental.d.ts
321 lines (294 loc) · 18.1 KB
/
rx.experimental.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
// Type definitions for RxJS-Experimental v2.2.28
// Project: https://github.com/Reactive-Extensions/RxJS/
// Definitions by: Igor Oleinikov <https://github.com/Igorbek>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="rx.d.ts"/>
declare module Rx {
interface Observable<T> {
/**
* Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions.
* This operator allows for a fluent style of writing queries that use the same sequence multiple times.
*
* @param selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence.
* @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
*/
let<TResult>(selector: (source: Observable<T>) => Observable<TResult>): Observable<TResult>;
/**
* Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions.
* This operator allows for a fluent style of writing queries that use the same sequence multiple times.
*
* @param selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence.
* @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
*/
letBind<TResult>(selector: (source: Observable<T>) => Observable<TResult>): Observable<TResult>;
/**
* Repeats source as long as condition holds emulating a do while loop.
* @param condition The condition which determines if the source will be repeated.
* @returns An observable sequence which is repeated as long as the condition holds.
*/
doWhile(condition: () => boolean): Observable<T>;
/**
* Expands an observable sequence by recursively invoking selector.
*
* @param selector Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again.
* @param [scheduler] Scheduler on which to perform the expansion. If not provided, this defaults to the current thread scheduler.
* @returns An observable sequence containing all the elements produced by the recursive expansion.
*/
expand(selector: (item: T) => Observable<T>, scheduler?: IScheduler): Observable<T>;
/**
* Runs two observable sequences in parallel and combines their last elemenets.
*
* @param second Second observable sequence or promise.
* @param resultSelector Result selector function to invoke with the last elements of both sequences.
* @returns An observable sequence with the result of calling the selector function with the last elements of both input sequences.
*/
forkJoin<TSecond, TResult>(second: Observable<TSecond>, resultSelector: (left: T, right: TSecond) => TResult): Observable<TResult>;
forkJoin<TSecond, TResult>(second: IPromise<TSecond>, resultSelector: (left: T, right: TSecond) => TResult): Observable<TResult>;
/**
* Comonadic bind operator.
* @param selector A transform function to apply to each element.
* @param [scheduler] Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler.
* @returns An observable sequence which results from the comonadic bind operation.
*/
manySelect<TResult>(selector: (item: Observable<T>, index: number, source: Observable<T>) => TResult, scheduler?: IScheduler): Observable<TResult>;
}
interface ObservableStatic {
/**
* Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9
*
* @example
* res = Rx.Observable.if(condition, obs1, obs2);
* @param condition The condition which determines if the thenSource or elseSource will be run.
* @param thenSource The observable sequence or promise that will be run if the condition function returns true.
* @param elseSource The observable sequence or promise that will be run if the condition function returns false.
* @returns An observable sequence which is either the thenSource or elseSource.
*/
if<T>(condition: () => boolean, thenSource: Observable<T>, elseSource: Observable<T>): Observable<T>;
if<T>(condition: () => boolean, thenSource: Observable<T>, elseSource: IPromise<T>): Observable<T>;
if<T>(condition: () => boolean, thenSource: IPromise<T>, elseSource: Observable<T>): Observable<T>;
if<T>(condition: () => boolean, thenSource: IPromise<T>, elseSource: IPromise<T>): Observable<T>;
/**
* Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9
*
* @example
* res = Rx.Observable.if(condition, obs1, scheduler);
* @param condition The condition which determines if the thenSource or empty sequence will be run.
* @param thenSource The observable sequence or promise that will be run if the condition function returns true.
* @param scheduler Scheduler used to create Rx.Observabe.Empty.
* @returns An observable sequence which is either the thenSource or empty sequence.
*/
if<T>(condition: () => boolean, thenSource: Observable<T>, scheduler?: IScheduler): Observable<T>;
if<T>(condition: () => boolean, thenSource: IPromise<T>, scheduler?: IScheduler): Observable<T>;
/**
* Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9
*
* @example
* res = Rx.Observable.if(condition, obs1, obs2);
* @param condition The condition which determines if the thenSource or elseSource will be run.
* @param thenSource The observable sequence or promise that will be run if the condition function returns true.
* @param elseSource The observable sequence or promise that will be run if the condition function returns false.
* @returns An observable sequence which is either the thenSource or elseSource.
*/
ifThen<T>(condition: () => boolean, thenSource: Observable<T>, elseSource: Observable<T>): Observable<T>;
ifThen<T>(condition: () => boolean, thenSource: Observable<T>, elseSource: IPromise<T>): Observable<T>;
ifThen<T>(condition: () => boolean, thenSource: IPromise<T>, elseSource: Observable<T>): Observable<T>;
ifThen<T>(condition: () => boolean, thenSource: IPromise<T>, elseSource: IPromise<T>): Observable<T>;
/**
* Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9
*
* @example
* res = Rx.Observable.if(condition, obs1, scheduler);
* @param condition The condition which determines if the thenSource or empty sequence will be run.
* @param thenSource The observable sequence or promise that will be run if the condition function returns true.
* @param scheduler Scheduler used to create Rx.Observabe.Empty.
* @returns An observable sequence which is either the thenSource or empty sequence.
*/
ifThen<T>(condition: () => boolean, thenSource: Observable<T>, scheduler?: IScheduler): Observable<T>;
ifThen<T>(condition: () => boolean, thenSource: IPromise<T>, scheduler?: IScheduler): Observable<T>;
/**
* Concatenates the observable sequences obtained by running the specified result selector for each element in source.
* There is an alias for this method called 'forIn' for browsers <IE9
* @param sources An array of values to turn into an observable sequence.
* @param resultSelector A function to apply to each item in the sources array to turn it into an observable sequence.
* @returns An observable sequence from the concatenated observable sequences.
*/
for<T, TResult>(sources: T[], resultSelector: (item: T) => Observable<TResult>): Observable<TResult>;
/**
* Concatenates the observable sequences obtained by running the specified result selector for each element in source.
* There is an alias for this method called 'forIn' for browsers <IE9
* @param sources An array of values to turn into an observable sequence.
* @param resultSelector A function to apply to each item in the sources array to turn it into an observable sequence.
* @returns An observable sequence from the concatenated observable sequences.
*/
forIn<T, TResult>(sources: T[], resultSelector: (item: T) => Observable<TResult>): Observable<TResult>;
/**
* Repeats source as long as condition holds emulating a while loop.
* There is an alias for this method called 'whileDo' for browsers <IE9
* @param condition The condition which determines if the source will be repeated.
* @param source The observable sequence or promise that will be run if the condition function returns true.
* @returns An observable sequence which is repeated as long as the condition holds.
*/
while<T>(condition: () => boolean, source: Observable<T>): Observable<T>;
while<T>(condition: () => boolean, source: IPromise<T>): Observable<T>;
/**
* Repeats source as long as condition holds emulating a while loop.
* There is an alias for this method called 'whileDo' for browsers <IE9
* @param condition The condition which determines if the source will be repeated.
* @param source The observable sequence or promise that will be run if the condition function returns true.
* @returns An observable sequence which is repeated as long as the condition holds.
*/
whileDo<T>(condition: () => boolean, source: Observable<T>): Observable<T>;
whileDo<T>(condition: () => boolean, source: IPromise<T>): Observable<T>;
/**
* Uses selector to determine which source in sources to use.
* There is an alias 'switchCase' for browsers <IE9.
*
* @example
* res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0);
* @param selector The function which extracts the value for to test in a case statement.
* @param sources A object which has keys which correspond to the case statement labels.
* @param elseSource The observable sequence or promise that will be run if the sources are not matched.
*
* @returns An observable sequence which is determined by a case statement.
*/
case<T>(selector: () => string, sources: { [key: string]: Observable<T>; }, elseSource: Observable<T>): Observable<T>;
case<T>(selector: () => string, sources: { [key: string]: IPromise<T>; }, elseSource: Observable<T>): Observable<T>;
case<T>(selector: () => string, sources: { [key: string]: Observable<T>; }, elseSource: IPromise<T>): Observable<T>;
case<T>(selector: () => string, sources: { [key: string]: IPromise<T>; }, elseSource: IPromise<T>): Observable<T>;
/**
* Uses selector to determine which source in sources to use.
* There is an alias 'switchCase' for browsers <IE9.
*
* @example
* res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 });
* res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler);
*
* @param selector The function which extracts the value for to test in a case statement.
* @param sources A object which has keys which correspond to the case statement labels.
* @param scheduler Scheduler used to create Rx.Observabe.Empty.
*
* @returns An observable sequence which is determined by a case statement.
*/
case<T>(selector: () => string, sources: { [key: string]: Observable<T>; }, scheduler?: IScheduler): Observable<T>;
case<T>(selector: () => string, sources: { [key: string]: IPromise<T>; }, scheduler?: IScheduler): Observable<T>;
/**
* Uses selector to determine which source in sources to use.
* There is an alias 'switchCase' for browsers <IE9.
*
* @example
* res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0);
* @param selector The function which extracts the value for to test in a case statement.
* @param sources A object which has keys which correspond to the case statement labels.
* @param elseSource The observable sequence or promise that will be run if the sources are not matched.
*
* @returns An observable sequence which is determined by a case statement.
*/
case<T>(selector: () => number, sources: { [key: number]: Observable<T>; }, elseSource: Observable<T>): Observable<T>;
case<T>(selector: () => number, sources: { [key: number]: IPromise<T>; }, elseSource: Observable<T>): Observable<T>;
case<T>(selector: () => number, sources: { [key: number]: Observable<T>; }, elseSource: IPromise<T>): Observable<T>;
case<T>(selector: () => number, sources: { [key: number]: IPromise<T>; }, elseSource: IPromise<T>): Observable<T>;
/**
* Uses selector to determine which source in sources to use.
* There is an alias 'switchCase' for browsers <IE9.
*
* @example
* res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 });
* res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler);
*
* @param selector The function which extracts the value for to test in a case statement.
* @param sources A object which has keys which correspond to the case statement labels.
* @param scheduler Scheduler used to create Rx.Observabe.Empty.
*
* @returns An observable sequence which is determined by a case statement.
*/
case<T>(selector: () => number, sources: { [key: number]: Observable<T>; }, scheduler?: IScheduler): Observable<T>;
case<T>(selector: () => number, sources: { [key: number]: IPromise<T>; }, scheduler?: IScheduler): Observable<T>;
/**
* Uses selector to determine which source in sources to use.
* There is an alias 'switchCase' for browsers <IE9.
*
* @example
* res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0);
* @param selector The function which extracts the value for to test in a case statement.
* @param sources A object which has keys which correspond to the case statement labels.
* @param elseSource The observable sequence or promise that will be run if the sources are not matched.
*
* @returns An observable sequence which is determined by a case statement.
*/
switchCase<T>(selector: () => string, sources: { [key: string]: Observable<T>; }, elseSource: Observable<T>): Observable<T>;
switchCase<T>(selector: () => string, sources: { [key: string]: IPromise<T>; }, elseSource: Observable<T>): Observable<T>;
switchCase<T>(selector: () => string, sources: { [key: string]: Observable<T>; }, elseSource: IPromise<T>): Observable<T>;
switchCase<T>(selector: () => string, sources: { [key: string]: IPromise<T>; }, elseSource: IPromise<T>): Observable<T>;
/**
* Uses selector to determine which source in sources to use.
* There is an alias 'switchCase' for browsers <IE9.
*
* @example
* res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 });
* res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler);
*
* @param selector The function which extracts the value for to test in a case statement.
* @param sources A object which has keys which correspond to the case statement labels.
* @param scheduler Scheduler used to create Rx.Observabe.Empty.
*
* @returns An observable sequence which is determined by a case statement.
*/
switchCase<T>(selector: () => string, sources: { [key: string]: Observable<T>; }, scheduler?: IScheduler): Observable<T>;
switchCase<T>(selector: () => string, sources: { [key: string]: IPromise<T>; }, scheduler?: IScheduler): Observable<T>;
/**
* Uses selector to determine which source in sources to use.
* There is an alias 'switchCase' for browsers <IE9.
*
* @example
* res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0);
* @param selector The function which extracts the value for to test in a case statement.
* @param sources A object which has keys which correspond to the case statement labels.
* @param elseSource The observable sequence or promise that will be run if the sources are not matched.
*
* @returns An observable sequence which is determined by a case statement.
*/
switchCase<T>(selector: () => number, sources: { [key: number]: Observable<T>; }, elseSource: Observable<T>): Observable<T>;
switchCase<T>(selector: () => number, sources: { [key: number]: IPromise<T>; }, elseSource: Observable<T>): Observable<T>;
switchCase<T>(selector: () => number, sources: { [key: number]: Observable<T>; }, elseSource: IPromise<T>): Observable<T>;
switchCase<T>(selector: () => number, sources: { [key: number]: IPromise<T>; }, elseSource: IPromise<T>): Observable<T>;
/**
* Uses selector to determine which source in sources to use.
* There is an alias 'switchCase' for browsers <IE9.
*
* @example
* res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 });
* res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler);
*
* @param selector The function which extracts the value for to test in a case statement.
* @param sources A object which has keys which correspond to the case statement labels.
* @param scheduler Scheduler used to create Rx.Observabe.Empty.
*
* @returns An observable sequence which is determined by a case statement.
*/
switchCase<T>(selector: () => number, sources: { [key: number]: Observable<T>; }, scheduler?: IScheduler): Observable<T>;
switchCase<T>(selector: () => number, sources: { [key: number]: IPromise<T>; }, scheduler?: IScheduler): Observable<T>;
/**
* Runs all observable sequences in parallel and collect their last elements.
*
* @example
* res = Rx.Observable.forkJoin([obs1, obs2]);
* @param sources Array of source sequences or promises.
* @returns An observable sequence with an array collecting the last elements of all the input sequences.
*/
forkJoin<T>(sources: Observable<T>[]): Observable<T[]>;
forkJoin<T>(sources: IPromise<T>[]): Observable<T[]>;
/**
* Runs all observable sequences in parallel and collect their last elements.
*
* @example
* res = Rx.Observable.forkJoin(obs1, obs2, ...);
* @param args Source sequences or promises.
* @returns An observable sequence with an array collecting the last elements of all the input sequences.
*/
forkJoin<T>(...args: Observable<T>[]): Observable<T[]>;
forkJoin<T>(...args: IPromise<T>[]): Observable<T[]>;
}
}
declare module "rx.experimental" {
export = Rx;
}