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

Unified Diff: packages/async/lib/src/delegate/stream_sink.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
Index: packages/async/lib/src/delegate/stream_sink.dart
diff --git a/packages/async/lib/src/delegate/stream_sink.dart b/packages/async/lib/src/delegate/stream_sink.dart
index b6ace650cb14c3d70a7ce711d8f1d890312c4d30..198df8a785dcfae6c0adf4c58194899505013a40 100644
--- a/packages/async/lib/src/delegate/stream_sink.dart
+++ b/packages/async/lib/src/delegate/stream_sink.dart
@@ -2,8 +2,6 @@
// 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.
-library async.delegate.stream_sink;
-
import 'dart:async';
/// Simple delegating wrapper around a [StreamSink].
@@ -16,8 +14,18 @@ class DelegatingStreamSink<T> implements StreamSink<T> {
Future get done => _sink.done;
/// Create delegating sink forwarding calls to [sink].
- DelegatingStreamSink(StreamSink sink)
- : _sink = sink;
+ DelegatingStreamSink(StreamSink<T> sink) : _sink = sink;
+
+ DelegatingStreamSink._(this._sink);
+
+ /// Creates a wrapper that coerces the type of [sink].
+ ///
+ /// Unlike [new StreamSink], this only requires its argument to be an instance
+ /// of `StreamSink`, not `StreamSink<T>`. This means that calls to [add] may
+ /// throw a [CastError] if the argument type doesn't match the reified type of
+ /// [sink].
+ static StreamSink<T> typed<T>(StreamSink sink) =>
+ sink is StreamSink<T> ? sink : new DelegatingStreamSink._(sink);
void add(T data) {
_sink.add(data);
« no previous file with comments | « packages/async/lib/src/delegate/stream_consumer.dart ('k') | packages/async/lib/src/delegate/stream_subscription.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698