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

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: 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
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..78d18a9909257481c0796618a56a698666f90dcd
--- /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 type of the sink returned by an inner
+/// transformer.
Lasse Reichstein Nielsen 2016/05/09 19:20:12 "coerces" isn't specific enough. At least say what
nweiz 2016/05/09 19:31:51 Done.
+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));
+}

Powered by Google App Engine
This is Rietveld 408576698