OLD | NEW |
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } | 137 } |
| 138 |
| 139 /** |
| 140 * 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). |
| 142 */ |
| 143 class _CustomEventStreamProvider<T extends Event> |
| 144 implements EventStreamProvider<T> { |
| 145 |
| 146 final _eventTypeGetter; |
| 147 const _CustomEventStreamProvider(this._eventTypeGetter); |
| 148 |
| 149 Stream<T> forTarget(EventTarget e, {bool useCapture: false}) { |
| 150 return new _EventStream(e, _eventTypeGetter(e), useCapture); |
| 151 } |
| 152 } |
OLD | NEW |