switchLatest<T> static method
Convert a Stream that emits Streams (aka a 'Higher Order Stream') into a single Stream that emits the items emitted by the most-recently-emitted of those Streams.
This Stream will unsubscribe from the previously-emitted Stream when a new Stream is emitted from the source Stream and subscribe to the new Stream.
Example
final switchLatestStream = SwitchLatestStream<String>(
Stream.fromIterable(<Stream<String>>[
Rx.timer('A', Duration(seconds: 2)),
Rx.timer('B', Duration(seconds: 1)),
Stream.value('C'),
]),
);
// Since the first two Streams do not emit data for 1-2 seconds, and the
// 3rd Stream will be emitted before that time, only data from the 3rd
// Stream will be emitted to the listener.
switchLatestStream.listen(print); // prints 'C'
Implementation
static Stream<T> switchLatest<T>(Stream<Stream<T>> streams) =>
SwitchLatestStream<T>(streams);