discard any items emitted by an Observable after a second Observable emits an item or terminates
The TakeUntil subscribes and begins mirroring the source Observable. It also monitors a second Observable that you provide. If this second Observable emits an item or sends a termination notification, the Observable returned by TakeUntil stops mirroring the source Observable and terminates.
takeUntil
takeUntil
In RxGroovy, this operator is implemented as takeUntil
. Note that the second Observable can cause takeUntil
to quit emitting items either by emitting an item or by issuing an onError
or onCompleted
notification.
takeUntil
does not by default operate on any particular Scheduler.
takeUntil(Observable)
A second version of this operator was released in RxGroovy 1.1. It uses a predicate function that evaluates the items emitted by the source Observable, rather than a second Observable, to terminate the resulting Observable sequence. In this way, it behaves in a similar way to TakeWhile.
takeUntil(Func1)
(RxGroovy 1.1)
takeUntil
In RxJava, this operator is implemented as takeUntil
. Note that the second Observable can cause takeUntil
to quit emitting items either by emitting an item or by issuing an onError
or onCompleted
notification.
takeUntil
does not by default operate on any particular Scheduler.
takeUntil(Observable)
A second version of this operator was released in RxJava 1.1. It uses a predicate function that evaluates the items emitted by the source Observable, rather than a second Observable, to terminate the resulting Observable sequence. In this way, it behaves in a similar way to TakeWhile.
takeUntil(Func1)
(RxJava 1.1)
takeUntil
RxJS implements the takeUntil
operator. You can pass it either an Observable or a Promise
that it will monitor for an item that triggers takeUntil
to stop mirroring the source Observable.
var source = Rx.Observable.timer(0, 1000) .takeUntil(Rx.Observable.timer(5000)); var subscription = source.subscribe( function (x) { console.log('Next: ' + x); }, function (err) { console.log('Error: ' + err); }, function () { console.log('Completed'); });
takeUntil
is found in each of the following distributions:
rx.js
rx.all.js
rx.all.compat.js
rx.compat.js
rx.lite.js
rx.lite.compat.js
There is also a takeUntilWithTime
operator to which you can pass an absolute time or an initial duration, but this is described on the Take operator page.
takeUntil
RxPHP implements this operator as takeUntil
.
Returns the values from the source observable sequence until the other observable sequence produces a value.
//from https://github.com/ReactiveX/RxPHP/blob/master/demo/take/take.php $observable = Rx\Observable::fromArray([21, 42, 63]); $observable ->take(2) ->subscribe($stdoutObserver);
© ReactiveX contributors
Licensed under the Apache License 2.0.
http://reactivex.io/documentation/operators/takeuntil.html