Introducing stream_channel

88 views
Skip to first unread message

Natalie Weizenbaum

unread,
Jan 28, 2016, 4:21:23 PM1/28/16
to General Dart Discussion
Hey Dartisans,

I just published a new package called stream_channel and I want to talk it up a bit. It fills in a hole in the Dart asynchrony landscape by providing a standard way of representing two-way communication: the eponymous StreamChannel class.

The interface itself is extremely simple:

abstract class StreamChannel<T> {
  /// The single-subscription stream that emits values from the
  /// other endpoint.
  Stream<T> get stream;

  /// The sink for sending values to the other endpoint.
  StreamSink<T> get sink;
}

There are also a few utility methods, but those can easily be implemented in terms of stream and sink using StreamChannelMixin.

This package will make it easier to deal with two-way communication in a general way, without being tightly coupled to context-specific APIs like ReceivePort or WebSocket. I'm planning on migrating packages like shelf_web_socket that handle two-way communication to use StreamChannels very soon.

Enjoy!
- Natalie

Anders Holmgren

unread,
Jan 28, 2016, 10:38:54 PM1/28/16
to Dart Misc
noice
Reply all
Reply to author
Forward
0 new messages