Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(890)

Unified Diff: lib/src/stream_sink_transformer/typed.dart

Issue 1947923003: Add APIs for asserting the types of transformers. (Closed) Base URL: git@github.com:dart-lang/async.git@master
Patch Set: Code review changes Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/stream_sink_transformer.dart ('k') | lib/src/typed_stream_transformer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/stream_sink_transformer/typed.dart
diff --git a/lib/src/stream_sink_transformer/typed.dart b/lib/src/stream_sink_transformer/typed.dart
new file mode 100644
index 0000000000000000000000000000000000000000..303bc08d76101d34679e1ada89945ab76d43fb7e
--- /dev/null
+++ b/lib/src/stream_sink_transformer/typed.dart
@@ -0,0 +1,20 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// 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 '../delegate/stream_sink.dart';
+import '../stream_sink_transformer.dart';
+
+/// A wrapper that coerces the generic type of the sink returned by an inner
+/// transformer to `S`.
+class TypeSafeStreamSinkTransformer<S, T>
+ implements StreamSinkTransformer<S, T> {
+ final StreamSinkTransformer _inner;
+
+ TypeSafeStreamSinkTransformer(this._inner);
+
+ StreamSink<S> bind(StreamSink<T> sink) =>
+ DelegatingStreamSink.typed(_inner.bind(sink));
+}
« no previous file with comments | « lib/src/stream_sink_transformer.dart ('k') | lib/src/typed_stream_transformer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698