|
| 1 | +// Type definitions for RxJS/Experimental |
| 2 | +// Project: https://github.com/Reactive-Extensions/RxJS/ |
| 3 | +// Definitions by: Igor Oleinikov <https://github.com/Igorbek> |
| 4 | +// Definitions: https://github.com/borisyankov/DefinitelyTyped |
| 5 | + |
| 6 | +/// <reference path="rx.js.d.ts"/> |
| 7 | + |
| 8 | +declare module Rx { |
| 9 | + |
| 10 | + interface IObservable<T> { |
| 11 | + /** |
| 12 | + * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. |
| 13 | + * This operator allows for a fluent style of writing queries that use the same sequence multiple times. |
| 14 | + * |
| 15 | + * @param selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence. |
| 16 | + * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. |
| 17 | + */ |
| 18 | + let<TResult>(selector: (source: IObservable<T>) => IObservable<TResult>): IObservable<TResult>; |
| 19 | + |
| 20 | + /** |
| 21 | + * Returns an observable sequence that is the result of invoking the selector on the source sequence, without sharing subscriptions. |
| 22 | + * This operator allows for a fluent style of writing queries that use the same sequence multiple times. |
| 23 | + * |
| 24 | + * @param selector Selector function which can use the source sequence as many times as needed, without sharing subscriptions to the source sequence. |
| 25 | + * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. |
| 26 | + */ |
| 27 | + letBind<TResult>(selector: (source: IObservable<T>) => IObservable<TResult>): IObservable<TResult>; |
| 28 | + |
| 29 | + /** |
| 30 | + * Repeats source as long as condition holds emulating a do while loop. |
| 31 | + * @param condition The condition which determines if the source will be repeated. |
| 32 | + * @returns An observable sequence which is repeated as long as the condition holds. |
| 33 | + */ |
| 34 | + doWhile(condition: () => boolean): IObservable<T>; |
| 35 | + |
| 36 | + /** |
| 37 | + * Expands an observable sequence by recursively invoking selector. |
| 38 | + * |
| 39 | + * @param selector Selector function to invoke for each produced element, resulting in another sequence to which the selector will be invoked recursively again. |
| 40 | + * @param [scheduler] Scheduler on which to perform the expansion. If not provided, this defaults to the current thread scheduler. |
| 41 | + * @returns An observable sequence containing all the elements produced by the recursive expansion. |
| 42 | + */ |
| 43 | + expand(selector: (item: T) => IObservable<T>, scheduler?: IScheduler): IObservable<T>; |
| 44 | + |
| 45 | + /** |
| 46 | + * Runs two observable sequences in parallel and combines their last elemenets. |
| 47 | + * |
| 48 | + * @param second Second observable sequence. |
| 49 | + * @param resultSelector Result selector function to invoke with the last elements of both sequences. |
| 50 | + * @returns An observable sequence with the result of calling the selector function with the last elements of both input sequences. |
| 51 | + */ |
| 52 | + forkJoin<TSecond, TResult>(second: IObservable<TSecond>, resultSelector: (left: T, right: TSecond) => TResult): IObservable<TResult>; |
| 53 | + |
| 54 | + /** |
| 55 | + * Comonadic bind operator. |
| 56 | + * @param selector A transform function to apply to each element. |
| 57 | + * @param [scheduler] Scheduler used to execute the operation. If not specified, defaults to the ImmediateScheduler. |
| 58 | + * @returns An observable sequence which results from the comonadic bind operation. |
| 59 | + */ |
| 60 | + manySelect<TResult>(selector: (item: IObservable<T>, index: number, source: IObservable<T>) => TResult, scheduler?: IScheduler): IObservable<TResult>; |
| 61 | + } |
| 62 | + |
| 63 | + interface Observable { |
| 64 | + /** |
| 65 | + * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9 |
| 66 | + * |
| 67 | + * @example |
| 68 | + * res = Rx.Observable.if(condition, obs1, obs2); |
| 69 | + * @param condition The condition which determines if the thenSource or elseSource will be run. |
| 70 | + * @param thenSource The observable sequence that will be run if the condition function returns true. |
| 71 | + * @param elseSource The observable sequence that will be run if the condition function returns false. |
| 72 | + * @returns An observable sequence which is either the thenSource or elseSource. |
| 73 | + */ |
| 74 | + if<T>(condition: () => boolean, thenSource: IObservable<T>, elseSource: IObservable<T>): IObservable<T>; |
| 75 | + |
| 76 | + /** |
| 77 | + * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9 |
| 78 | + * |
| 79 | + * @example |
| 80 | + * res = Rx.Observable.if(condition, obs1, scheduler); |
| 81 | + * @param condition The condition which determines if the thenSource or empty sequence will be run. |
| 82 | + * @param thenSource The observable sequence that will be run if the condition function returns true. |
| 83 | + * @param scheduler Scheduler used to create Rx.Observabe.Empty. |
| 84 | + * @returns An observable sequence which is either the thenSource or empty sequence. |
| 85 | + */ |
| 86 | + if<T>(condition: () => boolean, thenSource: IObservable<T>, scheduler?: IScheduler): IObservable<T>; |
| 87 | + |
| 88 | + /** |
| 89 | + * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9 |
| 90 | + * |
| 91 | + * @example |
| 92 | + * res = Rx.Observable.if(condition, obs1, obs2); |
| 93 | + * @param condition The condition which determines if the thenSource or elseSource will be run. |
| 94 | + * @param thenSource The observable sequence that will be run if the condition function returns true. |
| 95 | + * @param elseSource The observable sequence that will be run if the condition function returns false. |
| 96 | + * @returns An observable sequence which is either the thenSource or elseSource. |
| 97 | + */ |
| 98 | + ifThen<T>(condition: () => boolean, thenSource: IObservable<T>, elseSource: IObservable<T>): IObservable<T>; |
| 99 | + |
| 100 | + /** |
| 101 | + * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers <IE9 |
| 102 | + * |
| 103 | + * @example |
| 104 | + * res = Rx.Observable.if(condition, obs1, scheduler); |
| 105 | + * @param condition The condition which determines if the thenSource or empty sequence will be run. |
| 106 | + * @param thenSource The observable sequence that will be run if the condition function returns true. |
| 107 | + * @param scheduler Scheduler used to create Rx.Observabe.Empty. |
| 108 | + * @returns An observable sequence which is either the thenSource or empty sequence. |
| 109 | + */ |
| 110 | + ifThen<T>(condition: () => boolean, thenSource: IObservable<T>, scheduler?: IScheduler): IObservable<T>; |
| 111 | + |
| 112 | + /** |
| 113 | + * Concatenates the observable sequences obtained by running the specified result selector for each element in source. |
| 114 | + * There is an alias for this method called 'forIn' for browsers <IE9 |
| 115 | + * @param sources An array of values to turn into an observable sequence. |
| 116 | + * @param resultSelector A function to apply to each item in the sources array to turn it into an observable sequence. |
| 117 | + * @returns An observable sequence from the concatenated observable sequences. |
| 118 | + */ |
| 119 | + for<T, TResult>(sources: T[], resultSelector: (item: T) => IObservable<TResult>): IObservable<TResult>; |
| 120 | + |
| 121 | + /** |
| 122 | + * Concatenates the observable sequences obtained by running the specified result selector for each element in source. |
| 123 | + * There is an alias for this method called 'forIn' for browsers <IE9 |
| 124 | + * @param sources An array of values to turn into an observable sequence. |
| 125 | + * @param resultSelector A function to apply to each item in the sources array to turn it into an observable sequence. |
| 126 | + * @returns An observable sequence from the concatenated observable sequences. |
| 127 | + */ |
| 128 | + forIn<T, TResult>(sources: T[], resultSelector: (item: T) => IObservable<TResult>): IObservable<TResult>; |
| 129 | + |
| 130 | + /** |
| 131 | + * Repeats source as long as condition holds emulating a while loop. |
| 132 | + * There is an alias for this method called 'whileDo' for browsers <IE9 |
| 133 | + * @param condition The condition which determines if the source will be repeated. |
| 134 | + * @param source The observable sequence that will be run if the condition function returns true. |
| 135 | + * @returns An observable sequence which is repeated as long as the condition holds. |
| 136 | + */ |
| 137 | + while<T>(condition: () => boolean, source: IObservable<T>): IObservable<T>; |
| 138 | + |
| 139 | + /** |
| 140 | + * Repeats source as long as condition holds emulating a while loop. |
| 141 | + * There is an alias for this method called 'whileDo' for browsers <IE9 |
| 142 | + * @param condition The condition which determines if the source will be repeated. |
| 143 | + * @param source The observable sequence that will be run if the condition function returns true. |
| 144 | + * @returns An observable sequence which is repeated as long as the condition holds. |
| 145 | + */ |
| 146 | + whileDo<T>(condition: () => boolean, source: IObservable<T>): IObservable<T>; |
| 147 | + |
| 148 | + /** |
| 149 | + * Uses selector to determine which source in sources to use. |
| 150 | + * There is an alias 'switchCase' for browsers <IE9. |
| 151 | + * |
| 152 | + * @example |
| 153 | + * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0); |
| 154 | + * @param selector The function which extracts the value for to test in a case statement. |
| 155 | + * @param sources A object which has keys which correspond to the case statement labels. |
| 156 | + * @param elseSource The observable sequence that will be run if the sources are not matched. |
| 157 | + * |
| 158 | + * @returns An observable sequence which is determined by a case statement. |
| 159 | + */ |
| 160 | + case<T>(selector: () => string, sources: { [key: string]: IObservable<T>; }, elseSource: IObservable<T>): IObservable<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 }); |
| 168 | + * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler); |
| 169 | + * |
| 170 | + * @param selector The function which extracts the value for to test in a case statement. |
| 171 | + * @param sources A object which has keys which correspond to the case statement labels. |
| 172 | + * @param scheduler Scheduler used to create Rx.Observabe.Empty. |
| 173 | + * |
| 174 | + * @returns An observable sequence which is determined by a case statement. |
| 175 | + */ |
| 176 | + case<T>(selector: () => string, sources: { [key: string]: IObservable<T>; }, scheduler?: IScheduler): IObservable<T>; |
| 177 | + |
| 178 | + /** |
| 179 | + * Uses selector to determine which source in sources to use. |
| 180 | + * There is an alias 'switchCase' for browsers <IE9. |
| 181 | + * |
| 182 | + * @example |
| 183 | + * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0); |
| 184 | + * @param selector The function which extracts the value for to test in a case statement. |
| 185 | + * @param sources A object which has keys which correspond to the case statement labels. |
| 186 | + * @param elseSource The observable sequence that will be run if the sources are not matched. |
| 187 | + * |
| 188 | + * @returns An observable sequence which is determined by a case statement. |
| 189 | + */ |
| 190 | + case<T>(selector: () => number, sources: { [key: number]: IObservable<T>; }, elseSource: IObservable<T>): IObservable<T>; |
| 191 | + |
| 192 | + /** |
| 193 | + * Uses selector to determine which source in sources to use. |
| 194 | + * There is an alias 'switchCase' for browsers <IE9. |
| 195 | + * |
| 196 | + * @example |
| 197 | + * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }); |
| 198 | + * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler); |
| 199 | + * |
| 200 | + * @param selector The function which extracts the value for to test in a case statement. |
| 201 | + * @param sources A object which has keys which correspond to the case statement labels. |
| 202 | + * @param scheduler Scheduler used to create Rx.Observabe.Empty. |
| 203 | + * |
| 204 | + * @returns An observable sequence which is determined by a case statement. |
| 205 | + */ |
| 206 | + case<T>(selector: () => number, sources: { [key: number]: IObservable<T>; }, scheduler?: IScheduler): IObservable<T>; |
| 207 | + |
| 208 | + /** |
| 209 | + * Uses selector to determine which source in sources to use. |
| 210 | + * There is an alias 'switchCase' for browsers <IE9. |
| 211 | + * |
| 212 | + * @example |
| 213 | + * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0); |
| 214 | + * @param selector The function which extracts the value for to test in a case statement. |
| 215 | + * @param sources A object which has keys which correspond to the case statement labels. |
| 216 | + * @param elseSource The observable sequence that will be run if the sources are not matched. |
| 217 | + * |
| 218 | + * @returns An observable sequence which is determined by a case statement. |
| 219 | + */ |
| 220 | + switchCase<T>(selector: () => string, sources: { [key: string]: IObservable<T>; }, elseSource: IObservable<T>): IObservable<T>; |
| 221 | + |
| 222 | + /** |
| 223 | + * Uses selector to determine which source in sources to use. |
| 224 | + * There is an alias 'switchCase' for browsers <IE9. |
| 225 | + * |
| 226 | + * @example |
| 227 | + * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }); |
| 228 | + * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler); |
| 229 | + * |
| 230 | + * @param selector The function which extracts the value for to test in a case statement. |
| 231 | + * @param sources A object which has keys which correspond to the case statement labels. |
| 232 | + * @param scheduler Scheduler used to create Rx.Observabe.Empty. |
| 233 | + * |
| 234 | + * @returns An observable sequence which is determined by a case statement. |
| 235 | + */ |
| 236 | + switchCase<T>(selector: () => string, sources: { [key: string]: IObservable<T>; }, scheduler?: IScheduler): IObservable<T>; |
| 237 | + |
| 238 | + /** |
| 239 | + * Uses selector to determine which source in sources to use. |
| 240 | + * There is an alias 'switchCase' for browsers <IE9. |
| 241 | + * |
| 242 | + * @example |
| 243 | + * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0); |
| 244 | + * @param selector The function which extracts the value for to test in a case statement. |
| 245 | + * @param sources A object which has keys which correspond to the case statement labels. |
| 246 | + * @param elseSource The observable sequence that will be run if the sources are not matched. |
| 247 | + * |
| 248 | + * @returns An observable sequence which is determined by a case statement. |
| 249 | + */ |
| 250 | + switchCase<T>(selector: () => number, sources: { [key: number]: IObservable<T>; }, elseSource: IObservable<T>): IObservable<T>; |
| 251 | + |
| 252 | + /** |
| 253 | + * Uses selector to determine which source in sources to use. |
| 254 | + * There is an alias 'switchCase' for browsers <IE9. |
| 255 | + * |
| 256 | + * @example |
| 257 | + * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }); |
| 258 | + * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, scheduler); |
| 259 | + * |
| 260 | + * @param selector The function which extracts the value for to test in a case statement. |
| 261 | + * @param sources A object which has keys which correspond to the case statement labels. |
| 262 | + * @param scheduler Scheduler used to create Rx.Observabe.Empty. |
| 263 | + * |
| 264 | + * @returns An observable sequence which is determined by a case statement. |
| 265 | + */ |
| 266 | + switchCase<T>(selector: () => number, sources: { [key: number]: IObservable<T>; }, scheduler?: IScheduler): IObservable<T>; |
| 267 | + |
| 268 | + /** |
| 269 | + * Runs all observable sequences in parallel and collect their last elements. |
| 270 | + * |
| 271 | + * @example |
| 272 | + * res = Rx.Observable.forkJoin([obs1, obs2]); |
| 273 | + * @param sources Array of source sequences. |
| 274 | + * @returns An observable sequence with an array collecting the last elements of all the input sequences. |
| 275 | + */ |
| 276 | + forkJoin<T>(sources: IObservable<T>[]): IObservable<T[]>; |
| 277 | + |
| 278 | + /** |
| 279 | + * Runs all observable sequences in parallel and collect their last elements. |
| 280 | + * |
| 281 | + * @example |
| 282 | + * res = Rx.Observable.forkJoin(obs1, obs2, ...); |
| 283 | + * @param args Source sequences. |
| 284 | + * @returns An observable sequence with an array collecting the last elements of all the input sequences. |
| 285 | + */ |
| 286 | + forkJoin<T>(...args: IObservable<T>[]): IObservable<T[]>; |
| 287 | + } |
| 288 | +} |
0 commit comments