Skip to content

Commit 7e55163

Browse files
authored
Fix the type args for StreamChannel.transform(). (flutter#7)
Closes flutter#6
1 parent edb6d24 commit 7e55163

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.6.1
2+
3+
* Fix the type of `StreamChannel.transform()`. This previously inverted the
4+
generic parameters, so it only really worked with transformers where both
5+
generic types were identical.
6+
17
## 1.6.0
28

39
* `Disconnector.disconnect()` now returns a future that completes when all the

lib/stream_channel.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ abstract class StreamChannel<T> {
108108
/// Transforms [this] using [transformer].
109109
///
110110
/// This is identical to calling `transformer.bind(channel)`.
111-
StreamChannel transform(StreamChannelTransformer<T, dynamic> transformer);
111+
StreamChannel/*<S>*/ transform/*<S>*/(
112+
StreamChannelTransformer<dynamic/*=S*/, T> transformer);
112113

113114
/// Transforms only the [stream] component of [this] using [transformer].
114115
StreamChannel<T> transformStream(StreamTransformer<T, T> transformer);
@@ -152,7 +153,8 @@ abstract class StreamChannelMixin<T> implements StreamChannel<T> {
152153
other.stream.pipe(sink);
153154
}
154155

155-
StreamChannel transform(StreamChannelTransformer<T, dynamic> transformer) =>
156+
StreamChannel/*<S>*/ transform/*<S>*/(
157+
StreamChannelTransformer<dynamic/*=S*/, T> transformer) =>
156158
transformer.bind(this);
157159

158160
StreamChannel<T> transformStream(StreamTransformer<T, T> transformer) =>

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: stream_channel
2-
version: 1.6.0
2+
version: 1.6.1
33
description: An abstraction for two-way communication channels.
44
author: Dart Team <[email protected]>
55
homepage: https://github.com/dart-lang/stream_channel

test/json_document_transformer_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import 'package:test/test.dart';
1111
void main() {
1212
var streamController;
1313
var sinkController;
14-
var channel;
14+
StreamChannel<String> channel;
1515
setUp(() {
1616
streamController = new StreamController();
1717
sinkController = new StreamController();
18-
channel = new StreamChannel(
18+
channel = new StreamChannel<String>(
1919
streamController.stream, sinkController.sink);
2020
});
2121

0 commit comments

Comments
 (0)