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

Unified Diff: lib/src/delegate/stream.dart

Issue 1870543004: Add typed wrapper functions to delegate classes. (Closed) Base URL: git@github.com:dart-lang/async.git@master
Patch Set: Created 4 years, 8 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/delegate/stream.dart
diff --git a/lib/src/delegate/stream.dart b/lib/src/delegate/stream.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7ea3da762b83b520fd77809104c971f3f1dbfed3
--- /dev/null
+++ b/lib/src/delegate/stream.dart
@@ -0,0 +1,27 @@
+// 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 '../typed/stream.dart';
+
+/// Simple delegating wrapper around a [Stream].
+///
+/// Subclasses can override individual methods, or use this to expose only the
+/// [Stream] methods of a subclass.
+///
+/// Note that this is identical to [StreamView] in `dart:async`. It's provided
+/// under this name for consistency with other `Delegating*` classes.
+class DelegatingStream<T> extends StreamView<T> {
+ DelegatingStream(Stream<T> stream) : super(stream);
+
+ /// Creates a wrapper that asserts the types of the events emitted by
+ /// [stream].
+ ///
+ /// This soundly converts a [Stream] without a generic type to a `Stream<T>`
+ /// by asserting that its events are instances of `T` whenever they're
+ /// accessed. If they're not, it throws a [CastError].
Lasse Reichstein Nielsen 2016/04/08 09:20:29 Same comments as for Future.
nweiz 2016/04/11 20:26:16 Done.
+ static Stream/*<T>*/ typed/*<T>*/(Stream stream) =>
+ stream is Stream/*<T>*/ ? stream : new TypeSafeStream/*<T>*/(stream);
+}

Powered by Google App Engine
This is Rietveld 408576698