StreamSplitter<T> class

A class that splits a single source stream into an arbitrary number of (single-subscription) streams (called "branch") that emit the same events.

Each branch will emit all the same values and errors as the source stream, regardless of which values have been emitted on other branches. This means that the splitter stores every event that has been emitted so far, which may consume a lot of memory. The user can call close to indicate that no more branches will be created, and this memory will be released.

The source stream is only listened to once a branch is created and listened to. It's paused when all branches are paused or when all branches are canceled, and resumed once there's at least one branch that's listening and unpaused. It's not canceled unless no branches are listening and close has been called.

Constructors

StreamSplitter(Stream<T> _stream)

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() Future
Indicates that no more branches will be requested via split.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
split() Stream<T>
Returns a single-subscription stream that's a copy of the input stream.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

splitFrom<T>(Stream<T> stream, [int? count]) List<Stream<T>>
Splits stream into count identical streams.