Table of Contents

Class MaxOperator

Namespace
RxSharp.Operators
Assembly
RxSharp.dll

Extension methods implementing the max operator.

public static class MaxOperator
Inheritance
System.Object
MaxOperator

Remarks

Built directly on the no-seed Reduce<T>(Observable<T>, Func<T, T, T>) overload, matching rxjs's own max.ts (itself a thin wrapper over reduce). Since that overload emits nothing for an empty source rather than erroring, so does Max<T>(Observable<T>) — matches rxjs exactly, verified against the 7.8.2 tag rather than assumed.

Methods

Max<T>(Observable<T>)

Emits the single largest value seen from source, once it completes, using the default Comparer<T> for T.

public static Observable<T> Max<T>(this Observable<T> source)

Parameters

source Observable<T>

The source sequence.

Returns

Observable<T>

An observable that emits the largest value seen, once source completes.

Type Parameters

T

The type of values emitted by source and of the output.

Remarks

If source completes without ever emitting, the output completes without emitting any value either.

Max<T>(Observable<T>, Func<T, T, int>)

Emits the single largest value seen from source (per comparer), once it completes.

public static Observable<T> Max<T>(this Observable<T> source, Func<T, T, int> comparer)

Parameters

source Observable<T>

The source sequence.

comparer Func<T, T, int>

A function returning a positive number if the first value is greater, matching Comparer<T>.Compare(T, T)'s contract.

Returns

Observable<T>

An observable that emits the largest value seen, once source completes.

Type Parameters

T

The type of values emitted by source and of the output.

Remarks

If source completes without ever emitting, the output completes without emitting any value either. If comparer throws, the exception is forwarded via OnError.