1 | import { Observable } from '../Observable';
|
---|
2 | import { MonoTypeOperatorFunction } from '../types';
|
---|
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 a value. Then, it completes.</span>
|
---|
9 | *
|
---|
10 | * ![](takeUntil.png)
|
---|
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, the output Observable stops mirroring the source Observable
|
---|
15 | * and completes. If the `notifier` doesn't emit any value and completes
|
---|
16 | * then `takeUntil` will pass all values.
|
---|
17 | *
|
---|
18 | * ## Example
|
---|
19 | * Tick every second until the first click happens
|
---|
20 | * ```ts
|
---|
21 | * import { fromEvent, interval } from 'rxjs';
|
---|
22 | * import { takeUntil } from 'rxjs/operators';
|
---|
23 | *
|
---|
24 | * const source = interval(1000);
|
---|
25 | * const clicks = fromEvent(document, 'click');
|
---|
26 | * const result = source.pipe(takeUntil(clicks));
|
---|
27 | * result.subscribe(x => console.log(x));
|
---|
28 | * ```
|
---|
29 | *
|
---|
30 | * @see {@link take}
|
---|
31 | * @see {@link takeLast}
|
---|
32 | * @see {@link takeWhile}
|
---|
33 | * @see {@link skip}
|
---|
34 | *
|
---|
35 | * @param {Observable} notifier The Observable whose first emitted value will
|
---|
36 | * cause the output Observable of `takeUntil` to stop emitting values from the
|
---|
37 | * source Observable.
|
---|
38 | * @return {Observable<T>} An Observable that emits the values from the source
|
---|
39 | * Observable until such time as `notifier` emits its first value.
|
---|
40 | * @method takeUntil
|
---|
41 | * @owner Observable
|
---|
42 | */
|
---|
43 | export declare function takeUntil<T>(notifier: Observable<any>): MonoTypeOperatorFunction<T>;
|
---|