Line data Source code
1 : // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 2 : // for details. All rights reserved. Use of this source code is governed by a 3 : // BSD-style license that can be found in the LICENSE file. 4 : 5 : import 'dart:async'; 6 : 7 : import '../stream_sink_transformer.dart'; 8 : 9 : /// A wrapper that coerces the generic type of the sink returned by an inner 10 : /// transformer to `S`. 11 : class TypeSafeStreamSinkTransformer<S, T> 12 : implements StreamSinkTransformer<S, T> { 13 : final StreamSinkTransformer _inner; 14 : 15 0 : TypeSafeStreamSinkTransformer(this._inner); 16 : 17 0 : @override 18 0 : StreamSink<S> bind(StreamSink<T> sink) => StreamController(sync: true) 19 0 : ..stream.cast<dynamic>().pipe(_inner.bind(sink)); 20 : }