Table of Contents

Class CountOperator

Namespace
RxSharp.Operators
Assembly
RxSharp.dll

Implements the Count operator. Mirrors rxjs's count.

public static class CountOperator
Inheritance
System.Object
CountOperator

Methods

Count<T>(Observable<T>)

Emits a single integer: the total number of values emitted by source, once it completes.

public static Observable<int> Count<T>(this Observable<T> source)

Parameters

source Observable<T>

The source observable to count.

Returns

Observable<int>

An observable that emits the total value count, then completes.

Type Parameters

T

The element type of the source observable.

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

Emits a single integer: the number of values emitted by source that satisfy predicate, once source completes.

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

Parameters

source Observable<T>

The source observable to count.

predicate Func<T, bool>

A function that tests each value; only matching values are counted.

Returns

Observable<int>

An observable that emits the matching value count, then completes.

Type Parameters

T

The element type of the source observable.

Remarks

If predicate throws, the exception is forwarded via OnError.

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

Emits a single integer: the number of values emitted by source that satisfy predicate (called with the value and its zero-based emission index), once source completes.

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

Parameters

source Observable<T>

The source observable to count.

predicate Func<T, int, bool>

A function that tests each value together with its index since subscription; only matching values are counted.

Returns

Observable<int>

An observable that emits the matching value count, then completes.

Type Parameters

T

The element type of the source observable.

Remarks

If predicate throws, the exception is forwarded via OnError.