a zip code crypto-currency system good for red ONLY

mergeAll.js 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /** PURE_IMPORTS_START ._mergeMap,.._util_identity PURE_IMPORTS_END */
  2. import { mergeMap } from './mergeMap';
  3. import { identity } from '../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. export function mergeAll(concurrent) {
  49. if (concurrent === void 0) {
  50. concurrent = Number.POSITIVE_INFINITY;
  51. }
  52. return mergeMap(identity, null, concurrent);
  53. }
  54. //# sourceMappingURL=mergeAll.js.map