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

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

Issue 12263046: Fixing DOM's EventStream.isBroadcast (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> asBroadcastStream() => this; 18 Stream<T> asBroadcastStream() => this;
19 bool get isBroadcast => true;
19 20
20 StreamSubscription<T> listen(void onData(T event), 21 StreamSubscription<T> listen(void onData(T event),
21 { void onError(AsyncError error), 22 { void onError(AsyncError error),
22 void onDone(), 23 void onDone(),
23 bool unsubscribeOnError}) { 24 bool unsubscribeOnError}) {
24 25
25 return new _EventStreamSubscription<T>( 26 return new _EventStreamSubscription<T>(
26 this._target, this._eventType, onData, this._useCapture); 27 this._target, this._eventType, onData, this._useCapture);
27 } 28 }
28 } 29 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 const _CustomEventStreamProvider(this._eventTypeGetter); 159 const _CustomEventStreamProvider(this._eventTypeGetter);
159 160
160 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) { 161 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) {
161 return new _EventStream(e, _eventTypeGetter(e), useCapture); 162 return new _EventStream(e, _eventTypeGetter(e), useCapture);
162 } 163 }
163 164
164 String getEventType(EventTarget target) { 165 String getEventType(EventTarget target) {
165 return _eventTypeGetter(target); 166 return _eventTypeGetter(target);
166 } 167 }
167 } 168 }
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