takeUntil.d.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { Observable } from '../Observable';
  2. import { MonoTypeOperatorFunction } from '../interfaces';
  3. /**
  4. * Emits the values emitted by the source Observable until a `notifier`
  5. * Observable emits a value.
  6. *
  7. * <span class="informal">Lets values pass until a second Observable,
  8. * `notifier`, emits something. Then, it completes.</span>
  9. *
  10. * <img src="./img/takeUntil.png" width="100%">
  11. *
  12. * `takeUntil` subscribes and begins mirroring the source Observable. It also
  13. * monitors a second Observable, `notifier` that you provide. If the `notifier`
  14. * emits a value or a complete notification, the output Observable stops
  15. * mirroring the source Observable and completes.
  16. *
  17. * @example <caption>Tick every second until the first click happens</caption>
  18. * var interval = Rx.Observable.interval(1000);
  19. * var clicks = Rx.Observable.fromEvent(document, 'click');
  20. * var result = interval.takeUntil(clicks);
  21. * result.subscribe(x => console.log(x));
  22. *
  23. * @see {@link take}
  24. * @see {@link takeLast}
  25. * @see {@link takeWhile}
  26. * @see {@link skip}
  27. *
  28. * @param {Observable} notifier The Observable whose first emitted value will
  29. * cause the output Observable of `takeUntil` to stop emitting values from the
  30. * source Observable.
  31. * @return {Observable<T>} An Observable that emits the values from the source
  32. * Observable until such time as `notifier` emits its first value.
  33. * @method takeUntil
  34. * @owner Observable
  35. */
  36. export declare function takeUntil<T>(notifier: Observable<any>): MonoTypeOperatorFunction<T>;