Front end of the Slack clone application.

mergeAll.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. "use strict";
  2. var mergeMap_1 = require('./mergeMap');
  3. var identity_1 = require('../util/identity');
  4. /**
  5. * Converts a higher-order Observable into a first-order Observable which
  6. * concurrently delivers all values that are emitted on the inner Observables.
  7. *
  8. * <span class="informal">Flattens an Observable-of-Observables.</span>
  9. *
  10. * <img src="./img/mergeAll.png" width="100%">
  11. *
  12. * `mergeAll` subscribes to an Observable that emits Observables, also known as
  13. * a higher-order Observable. Each time it observes one of these emitted inner
  14. * Observables, it subscribes to that and delivers all the values from the
  15. * inner Observable on the output Observable. The output Observable only
  16. * completes once all inner Observables have completed. Any error delivered by
  17. * a inner Observable will be immediately emitted on the output Observable.
  18. *
  19. * @example <caption>Spawn a new interval Observable for each click event, and blend their outputs as one Observable</caption>
  20. * var clicks = Rx.Observable.fromEvent(document, 'click');
  21. * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000));
  22. * var firstOrder = higherOrder.mergeAll();
  23. * firstOrder.subscribe(x => console.log(x));
  24. *
  25. * @example <caption>Count from 0 to 9 every second for each click, but only allow 2 concurrent timers</caption>
  26. * var clicks = Rx.Observable.fromEvent(document, 'click');
  27. * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000).take(10));
  28. * var firstOrder = higherOrder.mergeAll(2);
  29. * firstOrder.subscribe(x => console.log(x));
  30. *
  31. * @see {@link combineAll}
  32. * @see {@link concatAll}
  33. * @see {@link exhaust}
  34. * @see {@link merge}
  35. * @see {@link mergeMap}
  36. * @see {@link mergeMapTo}
  37. * @see {@link mergeScan}
  38. * @see {@link switch}
  39. * @see {@link zipAll}
  40. *
  41. * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of inner
  42. * Observables being subscribed to concurrently.
  43. * @return {Observable} An Observable that emits values coming from all the
  44. * inner Observables emitted by the source Observable.
  45. * @method mergeAll
  46. * @owner Observable
  47. */
  48. function mergeAll(concurrent) {
  49. if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
  50. return mergeMap_1.mergeMap(identity_1.identity, null, concurrent);
  51. }
  52. exports.mergeAll = mergeAll;
  53. //# sourceMappingURL=mergeAll.js.map