| Index: lib/src/stream_channel_transformer.dart
|
| diff --git a/lib/src/stream_channel_transformer.dart b/lib/src/stream_channel_transformer.dart
|
| index ac980859daa2f48564a2ebc391cedd3537c3ddd8..ca09ea16bec34d6fb00dc0cd29f72848a7bb04ce 100644
|
| --- a/lib/src/stream_channel_transformer.dart
|
| +++ b/lib/src/stream_channel_transformer.dart
|
| @@ -8,6 +8,7 @@ import 'dart:convert';
|
| import 'package:async/async.dart';
|
|
|
| import '../stream_channel.dart';
|
| +import 'transformer/typed.dart';
|
|
|
| /// A [StreamChannelTransformer] transforms the events being passed to and
|
| /// emitted by a [StreamChannel].
|
| @@ -24,6 +25,21 @@ class StreamChannelTransformer<S, T> {
|
| /// The transformer to use on the channel's sink.
|
| final StreamSinkTransformer<S, T> _sinkTransformer;
|
|
|
| + /// Creates a wrapper that coerces the type of [transformer].
|
| + ///
|
| + /// This soundly converts a [StreamChannelTransformer] to a
|
| + /// `StreamChannelTransformer<S, T>`, regardless of its original generic type,
|
| + /// by asserting that the events emitted by the transformed channel's stream
|
| + /// are instances of `T` whenever they're provided. If they're not, the stream
|
| + /// throws a [CastError]. This also means that calls to [StreamSink.add] on
|
| + /// the transformed channel's sink may throw a [CastError] if the argument
|
| + /// type doesn't match the reified type of the sink.
|
| + static StreamChannelTransformer/*<S, T>*/ typed/*<S, T>*/(
|
| + StreamChannelTransformer transformer) =>
|
| + transformer is StreamChannelTransformer/*<S, T>*/
|
| + ? transformer
|
| + : new TypeSafeStreamChannelTransformer(transformer);
|
| +
|
| /// Creates a [StreamChannelTransformer] from existing stream and sink
|
| /// transformers.
|
| const StreamChannelTransformer(
|
|
|