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

Side by Side Diff: tools/dom/src/EventStreamProvider.dart

Issue 12061002: Fixing type check error using Stream.take in dart2js checked mode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « tests/html/streams_test.dart ('k') | no next file » | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of html; 5 part of html;
6 6
7 /** 7 /**
8 * Adapter for exposing DOM events as Dart streams. 8 * Adapter for exposing DOM events as Dart streams.
9 */ 9 */
10 class _EventStream<T extends Event> extends Stream<T> { 10 class _EventStream<T extends Event> extends Stream<T> {
11 final EventTarget _target; 11 final EventTarget _target;
12 final String _eventType; 12 final String _eventType;
13 final bool _useCapture; 13 final bool _useCapture;
14 14
15 _EventStream(this._target, this._eventType, this._useCapture); 15 _EventStream(this._target, this._eventType, this._useCapture);
16 16
17 // DOM events are inherently multi-subscribers. 17 // DOM events are inherently multi-subscribers.
18 Stream<T> asMultiSubscriberStream() => this; 18 Stream<T> asBroadcastStream() => this;
19 19
20 StreamSubscription<T> listen(void onData(T event), 20 StreamSubscription<T> listen(void onData(T event),
21 { void onError(AsyncError error), 21 { void onError(AsyncError error),
22 void onDone(), 22 void onDone(),
23 bool unsubscribeOnError}) { 23 bool unsubscribeOnError}) {
24 24
25 return new _EventStreamSubscription<T>( 25 return new _EventStreamSubscription<T>(
26 this._target, this._eventType, onData, this._useCapture); 26 this._target, this._eventType, onData, this._useCapture);
27 } 27 }
28 } 28 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 class _CustomEventStreamProvider<T extends Event> 143 class _CustomEventStreamProvider<T extends Event>
144 implements EventStreamProvider<T> { 144 implements EventStreamProvider<T> {
145 145
146 final _eventTypeGetter; 146 final _eventTypeGetter;
147 const _CustomEventStreamProvider(this._eventTypeGetter); 147 const _CustomEventStreamProvider(this._eventTypeGetter);
148 148
149 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) { 149 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) {
150 return new _EventStream(e, _eventTypeGetter(e), useCapture); 150 return new _EventStream(e, _eventTypeGetter(e), useCapture);
151 } 151 }
152 } 152 }
OLDNEW
« no previous file with comments | « tests/html/streams_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698