Front end of the Slack clone application.

mergeMap.js 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { mergeMap as higherOrderMergeMap } from '../operators/mergeMap';
  2. /* tslint:enable:max-line-length */
  3. /**
  4. * Projects each source value to an Observable which is merged in the output
  5. * Observable.
  6. *
  7. * <span class="informal">Maps each value to an Observable, then flattens all of
  8. * these inner Observables using {@link mergeAll}.</span>
  9. *
  10. * <img src="./img/mergeMap.png" width="100%">
  11. *
  12. * Returns an Observable that emits items based on applying a function that you
  13. * supply to each item emitted by the source Observable, where that function
  14. * returns an Observable, and then merging those resulting Observables and
  15. * emitting the results of this merger.
  16. *
  17. * @example <caption>Map and flatten each letter to an Observable ticking every 1 second</caption>
  18. * var letters = Rx.Observable.of('a', 'b', 'c');
  19. * var result = letters.mergeMap(x =>
  20. * Rx.Observable.interval(1000).map(i => x+i)
  21. * );
  22. * result.subscribe(x => console.log(x));
  23. *
  24. * // Results in the following:
  25. * // a0
  26. * // b0
  27. * // c0
  28. * // a1
  29. * // b1
  30. * // c1
  31. * // continues to list a,b,c with respective ascending integers
  32. *
  33. * @see {@link concatMap}
  34. * @see {@link exhaustMap}
  35. * @see {@link merge}
  36. * @see {@link mergeAll}
  37. * @see {@link mergeMapTo}
  38. * @see {@link mergeScan}
  39. * @see {@link switchMap}
  40. *
  41. * @param {function(value: T, ?index: number): ObservableInput} project A function
  42. * that, when applied to an item emitted by the source Observable, returns an
  43. * Observable.
  44. * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector]
  45. * A function to produce the value on the output Observable based on the values
  46. * and the indices of the source (outer) emission and the inner Observable
  47. * emission. The arguments passed to this function are:
  48. * - `outerValue`: the value that came from the source
  49. * - `innerValue`: the value that came from the projected Observable
  50. * - `outerIndex`: the "index" of the value that came from the source
  51. * - `innerIndex`: the "index" of the value from the projected Observable
  52. * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
  53. * Observables being subscribed to concurrently.
  54. * @return {Observable} An Observable that emits the result of applying the
  55. * projection function (and the optional `resultSelector`) to each item emitted
  56. * by the source Observable and merging the results of the Observables obtained
  57. * from this transformation.
  58. * @method mergeMap
  59. * @owner Observable
  60. */
  61. export function mergeMap(project, resultSelector, concurrent = Number.POSITIVE_INFINITY) {
  62. return higherOrderMergeMap(project, resultSelector, concurrent)(this);
  63. }
  64. //# sourceMappingURL=mergeMap.js.map