Table of Contents

Class FindIndexOperator

Namespace
RxSharp.Operators
Assembly
RxSharp.dll

Implements the FindIndex operator. Mirrors rxjs's findIndex.

public static class FindIndexOperator
Inheritance
System.Object
FindIndexOperator

Methods

FindIndex<T>(Observable<T>, Func<T, bool>)

Emits only the zero-based index of the first value from source that satisfies predicate, then completes.

public static Observable<int> FindIndex<T>(this Observable<T> source, Func<T, bool> predicate)

Parameters

source Observable<T>

The source observable to search.

predicate Func<T, bool>

A function that tests each value.

Returns

Observable<int>

An observable of the index of the first matching value, or -1 if none is found.

Type Parameters

T

The element type of the source observable.

Remarks

Like Find<T>(Observable<T>, Func<T, bool>), but emits the index of the match instead of the value itself. If no value satisfies predicate before source completes, the result emits -1 and completes normally (no error). If predicate throws, the exception is forwarded via OnError.

FindIndex<T>(Observable<T>, Func<T, int, bool>)

Emits only the zero-based index of the first value from source that satisfies predicate (called with the value and its zero-based emission index), then completes.

public static Observable<int> FindIndex<T>(this Observable<T> source, Func<T, int, bool> predicate)

Parameters

source Observable<T>

The source observable to search.

predicate Func<T, int, bool>

A function that tests each value together with its index since subscription.

Returns

Observable<int>

An observable of the index of the first matching value, or -1 if none is found.

Type Parameters

T

The element type of the source observable.

Remarks

Like Find<T>(Observable<T>, Func<T, int, bool>), but emits the index of the match instead of the value itself. If no value satisfies predicate before source completes, the result emits -1 and completes normally (no error). If predicate throws, the exception is forwarded via OnError.