Front end of the Slack clone application.

exhaustMap.js 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. "use strict";
  2. var exhaustMap_1 = require('../operators/exhaustMap');
  3. /* tslint:enable:max-line-length */
  4. /**
  5. * Projects each source value to an Observable which is merged in the output
  6. * Observable only if the previous projected Observable has completed.
  7. *
  8. * <span class="informal">Maps each value to an Observable, then flattens all of
  9. * these inner Observables using {@link exhaust}.</span>
  10. *
  11. * <img src="./img/exhaustMap.png" width="100%">
  12. *
  13. * Returns an Observable that emits items based on applying a function that you
  14. * supply to each item emitted by the source Observable, where that function
  15. * returns an (so-called "inner") Observable. When it projects a source value to
  16. * an Observable, the output Observable begins emitting the items emitted by
  17. * that projected Observable. However, `exhaustMap` ignores every new projected
  18. * Observable if the previous projected Observable has not yet completed. Once
  19. * that one completes, it will accept and flatten the next projected Observable
  20. * and repeat this process.
  21. *
  22. * @example <caption>Run a finite timer for each click, only if there is no currently active timer</caption>
  23. * var clicks = Rx.Observable.fromEvent(document, 'click');
  24. * var result = clicks.exhaustMap((ev) => Rx.Observable.interval(1000).take(5));
  25. * result.subscribe(x => console.log(x));
  26. *
  27. * @see {@link concatMap}
  28. * @see {@link exhaust}
  29. * @see {@link mergeMap}
  30. * @see {@link switchMap}
  31. *
  32. * @param {function(value: T, ?index: number): ObservableInput} project A function
  33. * that, when applied to an item emitted by the source Observable, returns an
  34. * Observable.
  35. * @param {function(outerValue: T, innerValue: I, outerIndex: number, innerIndex: number): any} [resultSelector]
  36. * A function to produce the value on the output Observable based on the values
  37. * and the indices of the source (outer) emission and the inner Observable
  38. * emission. The arguments passed to this function are:
  39. * - `outerValue`: the value that came from the source
  40. * - `innerValue`: the value that came from the projected Observable
  41. * - `outerIndex`: the "index" of the value that came from the source
  42. * - `innerIndex`: the "index" of the value from the projected Observable
  43. * @return {Observable} An Observable containing projected Observables
  44. * of each item of the source, ignoring projected Observables that start before
  45. * their preceding Observable has completed.
  46. * @method exhaustMap
  47. * @owner Observable
  48. */
  49. function exhaustMap(project, resultSelector) {
  50. return exhaustMap_1.exhaustMap(project, resultSelector)(this);
  51. }
  52. exports.exhaustMap = exhaustMap;
  53. //# sourceMappingURL=exhaustMap.js.map