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

Side by Side Diff: lib/src/delegate/event_sink.dart

Issue 2660333005: Change generic comment syntax to real generic syntax. (Closed)
Patch Set: Update version. Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/delegate/future.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 6
7 /// Simple delegating wrapper around an [EventSink]. 7 /// Simple delegating wrapper around an [EventSink].
8 /// 8 ///
9 /// Subclasses can override individual methods, or use this to expose only the 9 /// Subclasses can override individual methods, or use this to expose only the
10 /// [EventSink] methods of a subclass. 10 /// [EventSink] methods of a subclass.
11 class DelegatingEventSink<T> implements EventSink<T> { 11 class DelegatingEventSink<T> implements EventSink<T> {
12 final EventSink _sink; 12 final EventSink _sink;
13 13
14 /// Create a delegating sink forwarding calls to [sink]. 14 /// Create a delegating sink forwarding calls to [sink].
15 DelegatingEventSink(EventSink<T> sink) : _sink = sink; 15 DelegatingEventSink(EventSink<T> sink) : _sink = sink;
16 16
17 DelegatingEventSink._(this._sink); 17 DelegatingEventSink._(this._sink);
18 18
19 /// Creates a wrapper that coerces the type of [sink]. 19 /// Creates a wrapper that coerces the type of [sink].
20 /// 20 ///
21 /// Unlike [new DelegatingEventSink], this only requires its argument to be an 21 /// Unlike [new DelegatingEventSink], this only requires its argument to be an
22 /// instance of `EventSink`, not `EventSink<T>`. This means that calls to 22 /// instance of `EventSink`, not `EventSink<T>`. This means that calls to
23 /// [add] may throw a [CastError] if the argument type doesn't match the 23 /// [add] may throw a [CastError] if the argument type doesn't match the
24 /// reified type of [sink]. 24 /// reified type of [sink].
25 static EventSink/*<T>*/ typed/*<T>*/(EventSink sink) => 25 static EventSink<T> typed<T>(EventSink sink) =>
26 sink is EventSink/*<T>*/ ? sink : new DelegatingEventSink._(sink); 26 sink is EventSink<T> ? sink : new DelegatingEventSink._(sink);
27 27
28 void add(T data) { 28 void add(T data) {
29 _sink.add(data); 29 _sink.add(data);
30 } 30 }
31 31
32 void addError(error, [StackTrace stackTrace]) { 32 void addError(error, [StackTrace stackTrace]) {
33 _sink.addError(error, stackTrace); 33 _sink.addError(error, stackTrace);
34 } 34 }
35 35
36 void close() { 36 void close() {
37 _sink.close(); 37 _sink.close();
38 } 38 }
39 } 39 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/delegate/future.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698