Class LastOperator
Implements the Last operator. Mirrors rxjs's last.
public static class LastOperator
- Inheritance
-
System.ObjectLastOperator
Methods
Last<T>(Observable<T>)
Emits only the last value from source, once it completes.
public static Observable<T> Last<T>(this Observable<T> source)
Parameters
sourceObservable<T>The source observable to take the last value from.
Returns
- Observable<T>
An observable of just the last value from
source.
Type Parameters
TThe element type of the source observable.
Remarks
If source completes without emitting any value, the result errors with an
EmptyErrorException instead of completing — this is what distinguishes Last()
from TakeLast(1).
Last<T>(Observable<T>, Func<T, bool>)
Emits only the last value from source that satisfies predicate, once
source completes.
public static Observable<T> Last<T>(this Observable<T> source, Func<T, bool> predicate)
Parameters
sourceObservable<T>The source observable to search.
predicateFunc<T, bool>A function that tests each value.
Returns
- Observable<T>
An observable of the last value from
sourcethat satisfiespredicate.
Type Parameters
TThe element type of the source observable.
Remarks
If no value satisfies predicate, the result errors with an EmptyErrorException.
If predicate throws, that exception is forwarded via OnError instead.
Last<T>(Observable<T>, Func<T, bool>, T)
Emits only the last value from source that satisfies predicate, or
defaultValue if none does before source completes.
public static Observable<T> Last<T>(this Observable<T> source, Func<T, bool> predicate, T defaultValue)
Parameters
sourceObservable<T>The source observable to search.
predicateFunc<T, bool>A function that tests each value.
defaultValueTThe value to emit if no value satisfies
predicate.
Returns
- Observable<T>
An observable of the last matching value, or
defaultValueif none is found.
Type Parameters
TThe element type of the source observable and the default value.
Remarks
If predicate throws, the exception is forwarded via OnError.
Last<T>(Observable<T>, Func<T, int, bool>)
Emits only the last value from source that satisfies predicate
(called with the value and its zero-based emission index), once source completes.
public static Observable<T> Last<T>(this Observable<T> source, Func<T, int, bool> predicate)
Parameters
sourceObservable<T>The source observable to search.
predicateFunc<T, int, bool>A function that tests each value together with its index since subscription.
Returns
- Observable<T>
An observable of the last value from
sourcethat satisfiespredicate.
Type Parameters
TThe element type of the source observable.
Remarks
If no value satisfies predicate, the result errors with an EmptyErrorException.
If predicate throws, that exception is forwarded via OnError instead.
Last<T>(Observable<T>, Func<T, int, bool>, T)
Emits only the last value from source that satisfies predicate
(called with the value and its zero-based emission index), or defaultValue if none
does before source completes.
public static Observable<T> Last<T>(this Observable<T> source, Func<T, int, bool> predicate, T defaultValue)
Parameters
sourceObservable<T>The source observable to search.
predicateFunc<T, int, bool>A function that tests each value together with its index since subscription.
defaultValueTThe value to emit if no value satisfies
predicate.
Returns
- Observable<T>
An observable of the last matching value, or
defaultValueif none is found.
Type Parameters
TThe element type of the source observable and the default value.
Remarks
If predicate throws, the exception is forwarded via OnError.
Last<T>(Observable<T>, T)
Emits only the last value from source, or defaultValue if it
completes without emitting any value.
public static Observable<T> Last<T>(this Observable<T> source, T defaultValue)
Parameters
sourceObservable<T>The source observable to take the last value from.
defaultValueTThe value to emit if
sourcecompletes without emitting anything.
Returns
- Observable<T>
An observable of the last value from
source, ordefaultValueif it is empty.
Type Parameters
TThe element type of the source observable and the default value.