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

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

Issue 12247002: Adding event type getter to EventStreamProvider. (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/wheelevent_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> {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 * 127 *
128 * MediaElement.pauseEvent.forTarget(document.body).listen(...); 128 * MediaElement.pauseEvent.forTarget(document.body).listen(...);
129 * 129 *
130 * See also: 130 * See also:
131 * 131 *
132 * [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventLis tener) 132 * [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventLis tener)
133 */ 133 */
134 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) { 134 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) {
135 return new _EventStream(e, _eventType, useCapture); 135 return new _EventStream(e, _eventType, useCapture);
136 } 136 }
137
138 /**
139 * Gets the type of the event which this would listen for on the specified
140 * event target.
141 *
142 * The target is necessary because some browsers may use different event names
143 * for the same purpose and the target allows differentiating browser support.
144 */
145 String getEventType(EventTarget target) {
146 return _eventType;
147 }
137 } 148 }
138 149
139 /** 150 /**
140 * A factory to expose DOM events as streams, where the DOM event name has to 151 * A factory to expose DOM events as streams, where the DOM event name has to
141 * be determined on the fly (for example, mouse wheel events). 152 * be determined on the fly (for example, mouse wheel events).
142 */ 153 */
143 class _CustomEventStreamProvider<T extends Event> 154 class _CustomEventStreamProvider<T extends Event>
144 implements EventStreamProvider<T> { 155 implements EventStreamProvider<T> {
145 156
146 final _eventTypeGetter; 157 final _eventTypeGetter;
147 const _CustomEventStreamProvider(this._eventTypeGetter); 158 const _CustomEventStreamProvider(this._eventTypeGetter);
148 159
149 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) { 160 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) {
150 return new _EventStream(e, _eventTypeGetter(e), useCapture); 161 return new _EventStream(e, _eventTypeGetter(e), useCapture);
151 } 162 }
163
164 String getEventType(EventTarget target) {
165 return _eventTypeGetter(target);
166 }
152 } 167 }
OLDNEW
« no previous file with comments | « tests/html/wheelevent_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698