1 |
|
2 |
|
3 | declare namespace Rx {
|
4 | interface Observable<T> {
|
5 | |
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | let<TResult>(selector: (source: Observable<T>) => Observable<TResult>): Observable<TResult>;
|
13 |
|
14 | /**
|
15 | * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions.
|
16 | * This operator allows for a fluent style of writing queries that use the same sequence multiple times.
|
17 | *
|
18 | * @param selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence.
|
19 | * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.
|
20 | */
|
21 | letBind<TResult>(selector: (source: Observable<T>) => Observable<TResult>): Observable<TResult>;
|
22 |
|
23 | /**
|
24 | * Repeats source as long as condition holds emulating a do while loop.
|
25 | * @param condition The condition which determines if the source will be repeated.
|
26 | * @returns An observable sequence which is repeated as long as the condition holds.
|
27 | */
|
28 | doWhile(condition: () => boolean): Observable<T>;
|
29 |
|
30 | /**
|
31 | * Expands an observable sequence by recursively invoking selector.
|
32 | *
|
33 | * @param selector Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again.
|
34 | * @param [scheduler] Scheduler on which to perform the expansion. If not provided, this defaults to the current thread scheduler.
|
35 | * @returns An observable sequence containing all the elements produced by the recursive expansion.
|
36 | */
|
37 | expand(selector: (item: T) => Observable<T>, scheduler?: IScheduler): Observable<T>;
|
38 |
|
39 | /**
|
40 | * Runs two observable sequences in parallel and combines their last elemenets.
|
41 | *
|
42 | * @param second Second observable sequence or promise.
|
43 | * @param resultSelector Result selector function to invoke with the last elements of both sequences.
|
44 | * @returns An observable sequence with the result of calling the selector function with the last elements of both input sequences.
|
45 | */
|
46 | forkJoin<TSecond, TResult>(
|
47 | second: Observable<TSecond>,
|
48 | resultSelector: (left: T, right: TSecond) => TResult,
|
49 | ): Observable<TResult>;
|
50 | forkJoin<TSecond, TResult>(
|
51 | second: IPromise<TSecond>,
|
52 | resultSelector: (left: T, right: TSecond) => TResult,
|
53 | ): Observable<TResult>;
|
54 |
|
55 | /**
|
56 | * Comonadic bind operator.
|
57 | * @param selector A transform function to apply to each element.
|
58 | * @param [scheduler] Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler.
|
59 | * @returns An observable sequence which results from the comonadic bind operation.
|
60 | */
|
61 | manySelect<TResult>(
|
62 | selector: (item: Observable<T>, index: number, source: Observable<T>) => TResult,
|
63 | scheduler?: IScheduler,
|
64 | ): Observable<TResult>;
|
65 | }
|
66 |
|
67 | interface ObservableStatic {
|
68 | /**
|
69 | * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9
|
70 | *
|
71 | * @example
|
72 | * res = Rx.Observable.if(condition, obs1, obs2);
|
73 | * @param condition The condition which determines if the thenSource or elseSource will be run.
|
74 | * @param thenSource The observable sequence or promise that will be run if the condition function returns true.
|
75 | * @param elseSource The observable sequence or promise that will be run if the condition function returns false.
|
76 | * @returns An observable sequence which is either the thenSource or elseSource.
|
77 | */
|
78 | if<T>(condition: () => boolean, thenSource: Observable<T>, elseSource: Observable<T>): Observable<T>;
|
79 | if<T>(condition: () => boolean, thenSource: Observable<T>, elseSource: IPromise<T>): Observable<T>;
|
80 | if<T>(condition: () => boolean, thenSource: IPromise<T>, elseSource: Observable<T>): Observable<T>;
|
81 | if<T>(condition: () => boolean, thenSource: IPromise<T>, elseSource: IPromise<T>): Observable<T>;
|
82 |
|
83 | /**
|
84 | * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9
|
85 | *
|
86 | * @example
|
87 | * res = Rx.Observable.if(condition, obs1, scheduler);
|
88 | * @param condition The condition which determines if the thenSource or empty sequence will be run.
|
89 | * @param thenSource The observable sequence or promise that will be run if the condition function returns true.
|
90 | * @param scheduler Scheduler used to create Rx.Observabe.Empty.
|
91 | * @returns An observable sequence which is either the thenSource or empty sequence.
|
92 | */
|
93 | if<T>(condition: () => boolean, thenSource: Observable<T>, scheduler?: IScheduler): Observable<T>;
|
94 | if<T>(condition: () => boolean, thenSource: IPromise<T>, scheduler?: IScheduler): Observable<T>;
|
95 |
|
96 | /**
|
97 | * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9
|
98 | *
|
99 | * @example
|
100 | * res = Rx.Observable.if(condition, obs1, obs2);
|
101 | * @param condition The condition which determines if the thenSource or elseSource will be run.
|
102 | * @param thenSource The observable sequence or promise that will be run if the condition function returns true.
|
103 | * @param elseSource The observable sequence or promise that will be run if the condition function returns false.
|
104 | * @returns An observable sequence which is either the thenSource or elseSource.
|
105 | */
|
106 | ifThen<T>(condition: () => boolean, thenSource: Observable<T>, elseSource: Observable<T>): Observable<T>;
|
107 | ifThen<T>(condition: () => boolean, thenSource: Observable<T>, elseSource: IPromise<T>): Observable<T>;
|
108 | ifThen<T>(condition: () => boolean, thenSource: IPromise<T>, elseSource: Observable<T>): Observable<T>;
|
109 | ifThen<T>(condition: () => boolean, thenSource: IPromise<T>, elseSource: IPromise<T>): Observable<T>;
|
110 |
|
111 | /**
|
112 | * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9
|
113 | *
|
114 | * @example
|
115 | * res = Rx.Observable.if(condition, obs1, scheduler);
|
116 | * @param condition The condition which determines if the thenSource or empty sequence will be run.
|
117 | * @param thenSource The observable sequence or promise that will be run if the condition function returns true.
|
118 | * @param scheduler Scheduler used to create Rx.Observabe.Empty.
|
119 | * @returns An observable sequence which is either the thenSource or empty sequence.
|
120 | */
|
121 | ifThen<T>(condition: () => boolean, thenSource: Observable<T>, scheduler?: IScheduler): Observable<T>;
|
122 | ifThen<T>(condition: () => boolean, thenSource: IPromise<T>, scheduler?: IScheduler): Observable<T>;
|
123 |
|
124 | /**
|
125 | * Concatenates the observable sequences obtained by running the specified result selector for each element in source.
|
126 | * There is an alias for this method called 'forIn' for browsers <IE9
|
127 | * @param sources An array of values to turn into an observable sequence.
|
128 | * @param resultSelector A function to apply to each item in the sources array to turn it into an observable sequence.
|
129 | * @returns An observable sequence from the concatenated observable sequences.
|
130 | */
|
131 | for<T, TResult>(sources: T[], resultSelector: (item: T) => Observable<TResult>): Observable<TResult>;
|
132 |
|
133 | /**
|
134 | * Concatenates the observable sequences obtained by running the specified result selector for each element in source.
|
135 | * There is an alias for this method called 'forIn' for browsers <IE9
|
136 | * @param sources An array of values to turn into an observable sequence.
|
137 | * @param resultSelector A function to apply to each item in the sources array to turn it into an observable sequence.
|
138 | * @returns An observable sequence from the concatenated observable sequences.
|
139 | */
|
140 | forIn<T, TResult>(sources: T[], resultSelector: (item: T) => Observable<TResult>): Observable<TResult>;
|
141 |
|
142 | /**
|
143 | * Repeats source as long as condition holds emulating a while loop.
|
144 | * There is an alias for this method called 'whileDo' for browsers <IE9
|
145 | * @param condition The condition which determines if the source will be repeated.
|
146 | * @param source The observable sequence or promise that will be run if the condition function returns true.
|
147 | * @returns An observable sequence which is repeated as long as the condition holds.
|
148 | */
|
149 | while<T>(condition: () => boolean, source: Observable<T>): Observable<T>;
|
150 | while<T>(condition: () => boolean, source: IPromise<T>): Observable<T>;
|
151 |
|
152 | /**
|
153 | * Repeats source as long as condition holds emulating a while loop.
|
154 | * There is an alias for this method called 'whileDo' for browsers <IE9
|
155 | * @param condition The condition which determines if the source will be repeated.
|
156 | * @param source The observable sequence or promise that will be run if the condition function returns true.
|
157 | * @returns An observable sequence which is repeated as long as the condition holds.
|
158 | */
|
159 | whileDo<T>(condition: () => boolean, source: Observable<T>): Observable<T>;
|
160 | whileDo<T>(condition: () => boolean, source: IPromise<T>): Observable<T>;
|
161 |
|
162 | /**
|
163 | * Uses selector to determine which source in sources to use.
|
164 | * There is an alias 'switchCase' for browsers <IE9.
|
165 | *
|
166 | * @example
|
167 | * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0);
|
168 | * @param selector The function which extracts the value for to test in a case statement.
|
169 | * @param sources A object which has keys which correspond to the case statement labels.
|
170 | * @param elseSource The observable sequence or promise that will be run if the sources are not matched.
|
171 | *
|
172 | * @returns An observable sequence which is determined by a case statement.
|
173 | */
|
174 | case<T>(
|
175 | selector: () => string,
|
176 | sources: { [key: string]: Observable<T> },
|
177 | elseSource: Observable<T>,
|
178 | ): Observable<T>;
|
179 | case<T>(
|
180 | selector: () => string,
|
181 | sources: { [key: string]: IPromise<T> },
|
182 | elseSource: Observable<T>,
|
183 | ): Observable<T>;
|
184 | case<T>(
|
185 | selector: () => string,
|
186 | sources: { [key: string]: Observable<T> },
|
187 | elseSource: IPromise<T>,
|
188 | ): Observable<T>;
|
189 | case<T>(
|
190 | selector: () => string,
|
191 | sources: { [key: string]: IPromise<T> },
|
192 | elseSource: IPromise<T>,
|
193 | ): Observable<T>;
|
194 |
|
195 | /**
|
196 | * Uses selector to determine which source in sources to use.
|
197 | * There is an alias 'switchCase' for browsers <IE9.
|
198 | *
|
199 | * @example
|
200 | * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 });
|
201 | * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler);
|
202 | *
|
203 | * @param selector The function which extracts the value for to test in a case statement.
|
204 | * @param sources A object which has keys which correspond to the case statement labels.
|
205 | * @param scheduler Scheduler used to create Rx.Observabe.Empty.
|
206 | *
|
207 | * @returns An observable sequence which is determined by a case statement.
|
208 | */
|
209 | case<T>(
|
210 | selector: () => string,
|
211 | sources: { [key: string]: Observable<T> },
|
212 | scheduler?: IScheduler,
|
213 | ): Observable<T>;
|
214 | case<T>(selector: () => string, sources: { [key: string]: IPromise<T> }, scheduler?: IScheduler): Observable<T>;
|
215 |
|
216 | /**
|
217 | * Uses selector to determine which source in sources to use.
|
218 | * There is an alias 'switchCase' for browsers <IE9.
|
219 | *
|
220 | * @example
|
221 | * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0);
|
222 | * @param selector The function which extracts the value for to test in a case statement.
|
223 | * @param sources A object which has keys which correspond to the case statement labels.
|
224 | * @param elseSource The observable sequence or promise that will be run if the sources are not matched.
|
225 | *
|
226 | * @returns An observable sequence which is determined by a case statement.
|
227 | */
|
228 | case<T>(
|
229 | selector: () => number,
|
230 | sources: { [key: number]: Observable<T> },
|
231 | elseSource: Observable<T>,
|
232 | ): Observable<T>;
|
233 | case<T>(
|
234 | selector: () => number,
|
235 | sources: { [key: number]: IPromise<T> },
|
236 | elseSource: Observable<T>,
|
237 | ): Observable<T>;
|
238 | case<T>(
|
239 | selector: () => number,
|
240 | sources: { [key: number]: Observable<T> },
|
241 | elseSource: IPromise<T>,
|
242 | ): Observable<T>;
|
243 | case<T>(
|
244 | selector: () => number,
|
245 | sources: { [key: number]: IPromise<T> },
|
246 | elseSource: IPromise<T>,
|
247 | ): Observable<T>;
|
248 |
|
249 | /**
|
250 | * Uses selector to determine which source in sources to use.
|
251 | * There is an alias 'switchCase' for browsers <IE9.
|
252 | *
|
253 | * @example
|
254 | * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 });
|
255 | * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler);
|
256 | *
|
257 | * @param selector The function which extracts the value for to test in a case statement.
|
258 | * @param sources A object which has keys which correspond to the case statement labels.
|
259 | * @param scheduler Scheduler used to create Rx.Observabe.Empty.
|
260 | *
|
261 | * @returns An observable sequence which is determined by a case statement.
|
262 | */
|
263 | case<T>(
|
264 | selector: () => number,
|
265 | sources: { [key: number]: Observable<T> },
|
266 | scheduler?: IScheduler,
|
267 | ): Observable<T>;
|
268 | case<T>(selector: () => number, sources: { [key: number]: IPromise<T> }, scheduler?: IScheduler): Observable<T>;
|
269 |
|
270 | /**
|
271 | * Uses selector to determine which source in sources to use.
|
272 | * There is an alias 'switchCase' for browsers <IE9.
|
273 | *
|
274 | * @example
|
275 | * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0);
|
276 | * @param selector The function which extracts the value for to test in a case statement.
|
277 | * @param sources A object which has keys which correspond to the case statement labels.
|
278 | * @param elseSource The observable sequence or promise that will be run if the sources are not matched.
|
279 | *
|
280 | * @returns An observable sequence which is determined by a case statement.
|
281 | */
|
282 | switchCase<T>(
|
283 | selector: () => string,
|
284 | sources: { [key: string]: Observable<T> },
|
285 | elseSource: Observable<T>,
|
286 | ): Observable<T>;
|
287 | switchCase<T>(
|
288 | selector: () => string,
|
289 | sources: { [key: string]: IPromise<T> },
|
290 | elseSource: Observable<T>,
|
291 | ): Observable<T>;
|
292 | switchCase<T>(
|
293 | selector: () => string,
|
294 | sources: { [key: string]: Observable<T> },
|
295 | elseSource: IPromise<T>,
|
296 | ): Observable<T>;
|
297 | switchCase<T>(
|
298 | selector: () => string,
|
299 | sources: { [key: string]: IPromise<T> },
|
300 | elseSource: IPromise<T>,
|
301 | ): Observable<T>;
|
302 |
|
303 | /**
|
304 | * Uses selector to determine which source in sources to use.
|
305 | * There is an alias 'switchCase' for browsers <IE9.
|
306 | *
|
307 | * @example
|
308 | * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 });
|
309 | * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler);
|
310 | *
|
311 | * @param selector The function which extracts the value for to test in a case statement.
|
312 | * @param sources A object which has keys which correspond to the case statement labels.
|
313 | * @param scheduler Scheduler used to create Rx.Observabe.Empty.
|
314 | *
|
315 | * @returns An observable sequence which is determined by a case statement.
|
316 | */
|
317 | switchCase<T>(
|
318 | selector: () => string,
|
319 | sources: { [key: string]: Observable<T> },
|
320 | scheduler?: IScheduler,
|
321 | ): Observable<T>;
|
322 | switchCase<T>(
|
323 | selector: () => string,
|
324 | sources: { [key: string]: IPromise<T> },
|
325 | scheduler?: IScheduler,
|
326 | ): Observable<T>;
|
327 |
|
328 | /**
|
329 | * Uses selector to determine which source in sources to use.
|
330 | * There is an alias 'switchCase' for browsers <IE9.
|
331 | *
|
332 | * @example
|
333 | * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0);
|
334 | * @param selector The function which extracts the value for to test in a case statement.
|
335 | * @param sources A object which has keys which correspond to the case statement labels.
|
336 | * @param elseSource The observable sequence or promise that will be run if the sources are not matched.
|
337 | *
|
338 | * @returns An observable sequence which is determined by a case statement.
|
339 | */
|
340 | switchCase<T>(
|
341 | selector: () => number,
|
342 | sources: { [key: number]: Observable<T> },
|
343 | elseSource: Observable<T>,
|
344 | ): Observable<T>;
|
345 | switchCase<T>(
|
346 | selector: () => number,
|
347 | sources: { [key: number]: IPromise<T> },
|
348 | elseSource: Observable<T>,
|
349 | ): Observable<T>;
|
350 | switchCase<T>(
|
351 | selector: () => number,
|
352 | sources: { [key: number]: Observable<T> },
|
353 | elseSource: IPromise<T>,
|
354 | ): Observable<T>;
|
355 | switchCase<T>(
|
356 | selector: () => number,
|
357 | sources: { [key: number]: IPromise<T> },
|
358 | elseSource: IPromise<T>,
|
359 | ): Observable<T>;
|
360 |
|
361 | /**
|
362 | * Uses selector to determine which source in sources to use.
|
363 | * There is an alias 'switchCase' for browsers <IE9.
|
364 | *
|
365 | * @example
|
366 | * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 });
|
367 | * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler);
|
368 | *
|
369 | * @param selector The function which extracts the value for to test in a case statement.
|
370 | * @param sources A object which has keys which correspond to the case statement labels.
|
371 | * @param scheduler Scheduler used to create Rx.Observabe.Empty.
|
372 | *
|
373 | * @returns An observable sequence which is determined by a case statement.
|
374 | */
|
375 | switchCase<T>(
|
376 | selector: () => number,
|
377 | sources: { [key: number]: Observable<T> },
|
378 | scheduler?: IScheduler,
|
379 | ): Observable<T>;
|
380 | switchCase<T>(
|
381 | selector: () => number,
|
382 | sources: { [key: number]: IPromise<T> },
|
383 | scheduler?: IScheduler,
|
384 | ): Observable<T>;
|
385 |
|
386 | /**
|
387 | * Runs all observable sequences in parallel and collect their last elements.
|
388 | *
|
389 | * @example
|
390 | * res = Rx.Observable.forkJoin([obs1, obs2]);
|
391 | * @param sources Array of source sequences or promises.
|
392 | * @returns An observable sequence with an array collecting the last elements of all the input sequences.
|
393 | */
|
394 | forkJoin<T>(sources: Array<Observable<T>>): Observable<T[]>;
|
395 | forkJoin<T>(sources: Array<IPromise<T>>): Observable<T[]>;
|
396 |
|
397 | /**
|
398 | * Runs all observable sequences in parallel and collect their last elements.
|
399 | *
|
400 | * @example
|
401 | * res = Rx.Observable.forkJoin(obs1, obs2, ...);
|
402 | * @param args Source sequences or promises.
|
403 | * @returns An observable sequence with an array collecting the last elements of all the input sequences.
|
404 | */
|
405 | forkJoin<T>(...args: Array<Observable<T>>): Observable<T[]>;
|
406 | forkJoin<T>(...args: Array<IPromise<T>>): Observable<T[]>;
|
407 | }
|
408 | }
|
409 |
|
410 | declare module "rx-lite-experimental" {
|
411 | export = Rx;
|
412 | }
|
413 |
|
\ | No newline at end of file |