The skip_until operator skips items emitted by a source observable until an item is emitted by another observable. The following figure shows the marble diagram of this operator:
Figure 9.31: The skip_until operator
Its prototype is the following:
Observable.skip_until(self, other)
Here, other is an observable being used to stop skipping items from the source observable.
Here is an example of the skip_until operator:
numbers = Subject()
trigger = Subject()
numbers.skip_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")
)
numbers.on_next(1)
numbers.on_next(2)
trigger.on_next(True)
numbers.on_next(3)
numbers.on_next(4)
numbers.on_completed()
The numbers observable emits two items before the trigger observable emits an item. Then, the numbers observable emits items 3 and 4.
This example gives the following result: