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 = new 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>
read-only
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

close() Future
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.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited