Take while

See also

  • Official ReactiveX documentation: TakeWhile

Returns elements from an observable sequence as long as a specified condition is true. The element’s index is used in the logic of the predicate function.

1 - source.take_while(lambda value: value < 10) 2 - source.take_while(lambda value, index: value < 10 or index < 10)

Keyword arguments: predicate – A function to test each element for a condition; the

second parameter of the function represents the index of the source element.

Returns an observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.