Table of Contents

Class FilterOperator

Namespace
RxSharp.Operators
Assembly
RxSharp.dll

Implements the Filter operator. Mirrors rxjs's filter.

public static class FilterOperator
Inheritance
System.Object
FilterOperator

Methods

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

Emits only the values from source for which predicate returns true.

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

Parameters

source Observable<T>

The source observable to filter.

predicate Func<T, bool>

A function that tests each value.

Returns

Observable<T>

An observable of the values from source that satisfy predicate.

Type Parameters

T

The 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.

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

Emits only the values from source for which predicate, called with the value and its zero-based emission index, returns true.

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

Parameters

source Observable<T>

The source observable to filter.

predicate Func<T, int, bool>

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

Returns

Observable<T>

An observable of the values from source that satisfy predicate.

Type Parameters

T

The element type of the source observable.

Remarks

If predicate throws, the exception is forwarded via OnError and the source subscription is torn down.