concatMapTo.d.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { Observable } from 'rxjs';
  2. /**
  3. * Projects each source value to the same Observable which is merged multiple
  4. * times in a serialized fashion on the output Observable.
  5. *
  6. * <span class="informal">It's like {@link concatMap}, but maps each value
  7. * always to the same inner Observable.</span>
  8. *
  9. * <img src="./img/concatMapTo.png" width="100%">
  10. *
  11. * Maps each source value to the given Observable `innerObservable` regardless
  12. * of the source value, and then flattens those resulting Observables into one
  13. * single Observable, which is the output Observable. Each new `innerObservable`
  14. * instance emitted on the output Observable is concatenated with the previous
  15. * `innerObservable` instance.
  16. *
  17. * __Warning:__ if source values arrive endlessly and faster than their
  18. * corresponding inner Observables can complete, it will result in memory issues
  19. * as inner Observables amass in an unbounded buffer waiting for their turn to
  20. * be subscribed to.
  21. *
  22. * Note: `concatMapTo` is equivalent to `mergeMapTo` with concurrency parameter
  23. * set to `1`.
  24. *
  25. * @example <caption>For each click event, tick every second from 0 to 3, with no concurrency</caption>
  26. * var clicks = Rx.Observable.fromEvent(document, 'click');
  27. * var result = clicks.concatMapTo(Rx.Observable.interval(1000).take(4));
  28. * result.subscribe(x => console.log(x));
  29. *
  30. * // Results in the following:
  31. * // (results are not concurrent)
  32. * // For every click on the "document" it will emit values 0 to 3 spaced
  33. * // on a 1000ms interval
  34. * // one click = 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3
  35. *
  36. * @see {@link concat}
  37. * @see {@link concatAll}
  38. * @see {@link concatMap}
  39. * @see {@link mergeMapTo}
  40. * @see {@link switchMapTo}
  41. *
  42. * @param {ObservableInput} innerObservable An Observable to replace each value from
  43. * the source Observable.
  44. * @return {Observable} An observable of values merged together by joining the
  45. * passed observable with itself, one after the other, for each value emitted
  46. * from the source.
  47. * @method concatMapTo
  48. * @owner Observable
  49. */
  50. export declare function concatMapTo<T, R>(this: Observable<T>, innerObservable: Observable<R>): Observable<R>;