bind method
override
Transforms the events sent to and emitted by channel
.
Creates a new channel. When events are passed to the returned channel's
sink, the transformer will transform them and pass the transformed
versions to channel.sink
. When events are emitted from the
channel.straem
, the transformer will transform them and pass the
transformed versions to the returned channel's stream.
Implementation
StreamChannel<Object> bind(StreamChannel<String> channel) {
var stream = channel.stream.map(_codec.decode);
var sink = new StreamSinkTransformer<Object, String>.fromHandlers(
handleData: (data, sink) {
sink.add(_codec.encode(data));
}).bind(channel.sink);
return new StreamChannel.withCloseGuarantee(stream, sink);
}