The take_until operator

The take_until operator emits items from its source observable until another observable emits an item. The following figure shows the marble diagram of this operator:

Figure 9.33: The take_until operator

Its prototype is the following:

Observable.take_until(self, other)

Here, other is an observable used to stop emitting items from the source observable.

Here is an example of the take_until operator:

numbers = Subject()trigger = Subject()numbers.take_until(trigger).subscribe(    on_next = lambda i: print("on_next {}".format(i)),    on_error = lambda e: print("on_error: {}".format(e)), on_completed = lambda: print("on_completed") ...

Get Hands-On Reactive Programming with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.