takeUntil.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var operators_1 = require("rxjs/operators");
  4. /**
  5. * Emits the values emitted by the source Observable until a `notifier`
  6. * Observable emits a value.
  7. *
  8. * <span class="informal">Lets values pass until a second Observable,
  9. * `notifier`, emits a value. Then, it completes.</span>
  10. *
  11. * <img src="./img/takeUntil.png" width="100%">
  12. *
  13. * `takeUntil` subscribes and begins mirroring the source Observable. It also
  14. * monitors a second Observable, `notifier` that you provide. If the `notifier`
  15. * emits a value, the output Observable stops mirroring the source Observable
  16. * and completes. If the `notifier` doesn't emit any value and completes
  17. * then `takeUntil` will pass all values.
  18. *
  19. * @example <caption>Tick every second until the first click happens</caption>
  20. * var interval = Rx.Observable.interval(1000);
  21. * var clicks = Rx.Observable.fromEvent(document, 'click');
  22. * var result = interval.takeUntil(clicks);
  23. * result.subscribe(x => console.log(x));
  24. *
  25. * @see {@link take}
  26. * @see {@link takeLast}
  27. * @see {@link takeWhile}
  28. * @see {@link skip}
  29. *
  30. * @param {Observable} notifier The Observable whose first emitted value will
  31. * cause the output Observable of `takeUntil` to stop emitting values from the
  32. * source Observable.
  33. * @return {Observable<T>} An Observable that emits the values from the source
  34. * Observable until such time as `notifier` emits its first value.
  35. * @method takeUntil
  36. * @owner Observable
  37. */
  38. function takeUntil(notifier) {
  39. return operators_1.takeUntil(notifier)(this);
  40. }
  41. exports.takeUntil = takeUntil;
  42. //# sourceMappingURL=takeUntil.js.map