StreamRouter<T> class
Splits a Stream of events into multiple Streams based on a set of predicates.
Using StreamRouter differs from Stream.where because events are only sent to one Stream. If more than one predicate matches the event, the event is sent to the stream created by the earlier call to route. Events not matched by a call to route are sent to the defaultStream.
Example:
import 'dart:html'; import 'package:quiver/async.dart';
var router = StreamRouter(window.onClick); var onRightClick = router.route((e) => e.button == 2); var onAltClick = router.route((e) => e.altKey); var onOtherClick router.defaultStream;
Constructors
-
StreamRouter(Stream<
T> incoming) -
Create a new StreamRouter that listens to the
incoming
stream.
Properties
-
defaultStream
→ Stream<
T> -
no setter
- 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 -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
route(
bool predicate(T event)) → Stream< T> -
Events that match
predicate
are sent to the stream created by this method, and not sent to any other router streams. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited