Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

mergeAll.d.ts 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { OperatorFunction, ObservableInput } from '../types';
  2. /**
  3. * Converts a higher-order Observable into a first-order Observable which
  4. * concurrently delivers all values that are emitted on the inner Observables.
  5. *
  6. * <span class="informal">Flattens an Observable-of-Observables.</span>
  7. *
  8. * ![](mergeAll.png)
  9. *
  10. * `mergeAll` subscribes to an Observable that emits Observables, also known as
  11. * a higher-order Observable. Each time it observes one of these emitted inner
  12. * Observables, it subscribes to that and delivers all the values from the
  13. * inner Observable on the output Observable. The output Observable only
  14. * completes once all inner Observables have completed. Any error delivered by
  15. * a inner Observable will be immediately emitted on the output Observable.
  16. *
  17. * ## Examples
  18. * Spawn a new interval Observable for each click event, and blend their outputs as one Observable
  19. * ```ts
  20. * import { fromEvent, interval } from 'rxjs';
  21. * import { map, mergeAll } from 'rxjs/operators';
  22. *
  23. * const clicks = fromEvent(document, 'click');
  24. * const higherOrder = clicks.pipe(map((ev) => interval(1000)));
  25. * const firstOrder = higherOrder.pipe(mergeAll());
  26. * firstOrder.subscribe(x => console.log(x));
  27. * ```
  28. *
  29. * Count from 0 to 9 every second for each click, but only allow 2 concurrent timers
  30. * ```ts
  31. * import { fromEvent, interval } from 'rxjs';
  32. * import { take, map, mergeAll } from 'rxjs/operators';
  33. *
  34. * const clicks = fromEvent(document, 'click');
  35. * const higherOrder = clicks.pipe(
  36. * map((ev) => interval(1000).pipe(take(10))),
  37. * );
  38. * const firstOrder = higherOrder.pipe(mergeAll(2));
  39. * firstOrder.subscribe(x => console.log(x));
  40. * ```
  41. *
  42. * @see {@link combineAll}
  43. * @see {@link concatAll}
  44. * @see {@link exhaust}
  45. * @see {@link merge}
  46. * @see {@link mergeMap}
  47. * @see {@link mergeMapTo}
  48. * @see {@link mergeScan}
  49. * @see {@link switchAll}
  50. * @see {@link switchMap}
  51. * @see {@link zipAll}
  52. *
  53. * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of inner
  54. * Observables being subscribed to concurrently.
  55. * @return {Observable} An Observable that emits values coming from all the
  56. * inner Observables emitted by the source Observable.
  57. * @method mergeAll
  58. * @owner Observable
  59. */
  60. export declare function mergeAll<T>(concurrent?: number): OperatorFunction<ObservableInput<T>, T>;