max method

AsObservableFuture<T> max ([Comparator<T> comparator ])

Converts a Stream into a Future that completes with the largest item emitted by the Stream.

This is similar to finding the max value in a list, but the values are asynchronous.

Example

final max = await new Observable.fromIterable([1, 2, 3]).max();

print(max); // prints 3

Example with custom Comparator

final observable = new Observable.fromIterable("short", "looooooong");
final max = await observable.max((a, b) => a.length - b.length);

print(max); // prints "looooooong"

Implementation

AsObservableFuture<T> max([Comparator<T> comparator]) =>
    new AsObservableFuture<T>(new StreamMaxFuture<T>(_stream, comparator));