Class TakeWhileOperator
Implements the TakeWhile operator. Mirrors rxjs's takeWhile.
public static class TakeWhileOperator
- Inheritance
-
System.ObjectTakeWhileOperator
Methods
TakeWhile<T>(Observable<T>, Func<T, bool>, bool)
Emits values from source for as long as predicate returns
true, then completes as soon as it returns false without waiting
for source itself to complete.
public static Observable<T> TakeWhile<T>(this Observable<T> source, Func<T, bool> predicate, bool inclusive = false)
Parameters
sourceObservable<T>The source observable to take values from.
predicateFunc<T, bool>A function that tests each value.
inclusiveboolIf true, the value that made
predicatereturn false is emitted before completing.
Returns
- Observable<T>
An observable of the values from
sourceup to (and, ifinclusive, including) the first one that failspredicate.
Type Parameters
TThe element type of the source observable.
Remarks
Equivalent to the indexed overload with the index ignored. If predicate throws, the exception is forwarded via OnError.
TakeWhile<T>(Observable<T>, Func<T, int, bool>, bool)
Emits values from source for as long as predicate, called with the
value and its zero-based emission index, returns true, then completes as soon as it
returns false without waiting for source itself to complete.
public static Observable<T> TakeWhile<T>(this Observable<T> source, Func<T, int, bool> predicate, bool inclusive = false)
Parameters
sourceObservable<T>The source observable to take values from.
predicateFunc<T, int, bool>A function that tests each value together with its index since subscription.
inclusiveboolIf true, the value that made
predicatereturn false is emitted before completing.
Returns
- Observable<T>
An observable of the values from
sourceup to (and, ifinclusive, including) the first one that failspredicate.
Type Parameters
TThe element type of the source observable.
Remarks
If predicate throws, the exception is forwarded via OnError.