race<T> static method

Stream<T> race<T>(
  1. Iterable<Stream<T>> streams
)

Given two or more source streams, emit all of the items from only the first of these streams to emit an item or notification.

If the provided streams is empty, the resulting sequence completes immediately without emitting any items.

Interactive marble diagram

Example

Rx.race([
  Rx.timer(1, Duration(days: 1)),
  Rx.timer(2, Duration(days: 2)),
  Rx.timer(3, Duration(seconds: 1))
]).listen(print); // prints 3

Implementation

static Stream<T> race<T>(Iterable<Stream<T>> streams) =>
    RaceStream<T>(streams);