max method

AsObservableFuture<T> max(
  1. [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.


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"


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