Skip to content

Commit

Permalink
Merge pull request flutter#18 from dart-lang/json-document-transforme…
Browse files Browse the repository at this point in the history
…r-bind

Fix JsonDocumentTransformer.bind for dart 2
  • Loading branch information
jakemac53 authored Apr 16, 2018
2 parents 1196a6a + 5753cf1 commit fe4f7c5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.6.5

* Fix an issue with `JsonDocumentTransformer.bind` where it created an internal
stream channel which didn't get a properly inferred type for its `sink`.

## 1.6.4

* Fix a race condition in `MultiChannel` where messages from a remote virtual
Expand Down
6 changes: 4 additions & 2 deletions lib/src/json_document_transformer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:async';
import 'dart:convert';

import 'package:async/async.dart';
Expand Down Expand Up @@ -35,9 +36,10 @@ class JsonDocumentTransformer

JsonDocumentTransformer._(this._codec);

StreamChannel bind(StreamChannel<String> channel) {
StreamChannel<Object> bind(StreamChannel<String> channel) {
var stream = channel.stream.map(_codec.decode);
var sink = new StreamSinkTransformer.fromHandlers(handleData: (data, sink) {
var sink = new StreamSinkTransformer<Object, String>.fromHandlers(
handleData: (data, sink) {
sink.add(_codec.encode(data));
}).bind(channel.sink);
return new StreamChannel.withCloseGuarantee(stream, sink);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: stream_channel
version: 1.6.4
version: 1.6.5
description: An abstraction for two-way communication channels.
author: Dart Team <[email protected]>
homepage: https://github.com/dart-lang/stream_channel
Expand Down

0 comments on commit fe4f7c5

Please sign in to comment.