UI for Zipcoin Blue

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. var switchAll_1 = require('../operators/switchAll');
  3. /**
  4. * Converts a higher-order Observable into a first-order Observable by
  5. * subscribing to only the most recently emitted of those inner Observables.
  6. *
  7. * <span class="informal">Flattens an Observable-of-Observables by dropping the
  8. * previous inner Observable once a new one appears.</span>
  9. *
  10. * <img src="./img/switch.png" width="100%">
  11. *
  12. * `switch` subscribes to an Observable that emits Observables, also known as a
  13. * higher-order Observable. Each time it observes one of these emitted inner
  14. * Observables, the output Observable subscribes to the inner Observable and
  15. * begins emitting the items emitted by that. So far, it behaves
  16. * like {@link mergeAll}. However, when a new inner Observable is emitted,
  17. * `switch` unsubscribes from the earlier-emitted inner Observable and
  18. * subscribes to the new inner Observable and begins emitting items from it. It
  19. * continues to behave like this for subsequent inner Observables.
  20. *
  21. * @example <caption>Rerun an interval Observable on every click event</caption>
  22. * var clicks = Rx.Observable.fromEvent(document, 'click');
  23. * // Each click event is mapped to an Observable that ticks every second
  24. * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000));
  25. * var switched = higherOrder.switch();
  26. * // The outcome is that `switched` is essentially a timer that restarts
  27. * // on every click. The interval Observables from older clicks do not merge
  28. * // with the current interval Observable.
  29. * switched.subscribe(x => console.log(x));
  30. *
  31. * @see {@link combineAll}
  32. * @see {@link concatAll}
  33. * @see {@link exhaust}
  34. * @see {@link mergeAll}
  35. * @see {@link switchMap}
  36. * @see {@link switchMapTo}
  37. * @see {@link zipAll}
  38. *
  39. * @return {Observable<T>} An Observable that emits the items emitted by the
  40. * Observable most recently emitted by the source Observable.
  41. * @method switch
  42. * @name switch
  43. * @owner Observable
  44. */
  45. function _switch() {
  46. return switchAll_1.switchAll()(this);
  47. }
  48. exports._switch = _switch;
  49. //# sourceMappingURL=switch.js.map