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

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

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 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 | « packages/async/lib/src/delegate/sink.dart ('k') | packages/async/lib/src/delegate/stream_consumer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/async/lib/src/delegate/stream.dart
diff --git a/packages/async/lib/src/delegate/stream.dart b/packages/async/lib/src/delegate/stream.dart
new file mode 100644
index 0000000000000000000000000000000000000000..d08b4ab828e589308b9f328c80b1db55936ee883
--- /dev/null
+++ b/packages/async/lib/src/delegate/stream.dart
@@ -0,0 +1,28 @@
+// 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 which throws if [stream]'s events aren't instances of
+ /// `T`.
+ ///
+ /// This soundly converts a [Stream] to a `Stream<T>`, regardless of its
+ /// original generic type, by asserting that its events are instances of `T`
+ /// whenever they're provided. If they're not, the stream throws a
+ /// [CastError].
+ static Stream<T> typed<T>(Stream stream) =>
+ stream is Stream<T> ? stream : new TypeSafeStream<T>(stream);
+}
« no previous file with comments | « packages/async/lib/src/delegate/sink.dart ('k') | packages/async/lib/src/delegate/stream_consumer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698