Front end of the Slack clone application.

mergeMapTo.js 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. "use strict";
  2. var mergeMapTo_1 = require('../operators/mergeMapTo');
  3. /* tslint:enable:max-line-length */
  4. /**
  5. * Projects each source value to the same Observable which is merged multiple
  6. * times in the output Observable.
  7. *
  8. * <span class="informal">It's like {@link mergeMap}, but maps each value always
  9. * to the same inner Observable.</span>
  10. *
  11. * <img src="./img/mergeMapTo.png" width="100%">
  12. *
  13. * Maps each source value to the given Observable `innerObservable` regardless
  14. * of the source value, and then merges those resulting Observables into one
  15. * single Observable, which is the output Observable.
  16. *
  17. * @example <caption>For each click event, start an interval Observable ticking every 1 second</caption>
  18. * var clicks = Rx.Observable.fromEvent(document, 'click');
  19. * var result = clicks.mergeMapTo(Rx.Observable.interval(1000));
  20. * result.subscribe(x => console.log(x));
  21. *
  22. * @see {@link concatMapTo}
  23. * @see {@link merge}
  24. * @see {@link mergeAll}
  25. * @see {@link mergeMap}
  26. * @see {@link mergeScan}
  27. * @see {@link switchMapTo}
  28. *
  29. * @param {ObservableInput} innerObservable An Observable to replace each value from
  30. * the source Observable.
  31. * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector]
  32. * A function to produce the value on the output Observable based on the values
  33. * and the indices of the source (outer) emission and the inner Observable
  34. * emission. The arguments passed to this function are:
  35. * - `outerValue`: the value that came from the source
  36. * - `innerValue`: the value that came from the projected Observable
  37. * - `outerIndex`: the "index" of the value that came from the source
  38. * - `innerIndex`: the "index" of the value from the projected Observable
  39. * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
  40. * Observables being subscribed to concurrently.
  41. * @return {Observable} An Observable that emits items from the given
  42. * `innerObservable` (and optionally transformed through `resultSelector`) every
  43. * time a value is emitted on the source Observable.
  44. * @method mergeMapTo
  45. * @owner Observable
  46. */
  47. function mergeMapTo(innerObservable, resultSelector, concurrent) {
  48. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  49. return mergeMapTo_1.mergeMapTo(innerObservable, resultSelector, concurrent)(this);
  50. }
  51. exports.mergeMapTo = mergeMapTo;
  52. //# sourceMappingURL=mergeMapTo.js.map