The skip_while operator skips items emitted from the source observable until the criteria are met. The following figure shows the marble diagram of this operator:
Figure 9.32: The skip_while operator
Its prototype is the following:
Observable.skip_while(self, predicate)
Here, predicate is a function being called each time an item is emitted from the source observable. When the predicate function returns True, then the skip_while operator starts emitting items of the source observable.
Here is an example of the skip_while operator:
numbers = Observable.from_([1, 2, 3, 4])
numbers.skip_while(lambda i: i < 2).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")
)
This example gives the following result: