a zip code crypto-currency system good for red ONLY

exhaustMap.js 2.5KB

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