| 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 * A factory to expose DOM events as Streams. | 8 * A factory to expose DOM events as Streams. |
| 9 */ | 9 */ |
| 10 class EventStreamProvider<T extends Event> { | 10 class EventStreamProvider<T extends Event> { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 * | 69 * |
| 70 * This may be used to capture DOM events: | 70 * This may be used to capture DOM events: |
| 71 * | 71 * |
| 72 * Element.keyDownEvent._forElementList(element, useCapture: true).listen(
...); | 72 * Element.keyDownEvent._forElementList(element, useCapture: true).listen(
...); |
| 73 * | 73 * |
| 74 * See also: | 74 * See also: |
| 75 * | 75 * |
| 76 * [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventLis
tener) | 76 * [addEventListener](http://docs.webplatform.org/wiki/dom/methods/addEventLis
tener) |
| 77 */ | 77 */ |
| 78 ElementStream<T> _forElementList(ElementList e, {bool useCapture: false}) { | 78 ElementStream<T> _forElementList(ElementList e, {bool useCapture: false}) { |
| 79 return new _ElementListEventStreamImpl(e, _eventType, useCapture); | 79 return new _ElementListEventStreamImpl<T>(e, _eventType, useCapture); |
| 80 } | 80 } |
| 81 | 81 |
| 82 /** | 82 /** |
| 83 * Gets the type of the event which this would listen for on the specified | 83 * Gets the type of the event which this would listen for on the specified |
| 84 * event target. | 84 * event target. |
| 85 * | 85 * |
| 86 * The target is necessary because some browsers may use different event names | 86 * The target is necessary because some browsers may use different event names |
| 87 * for the same purpose and the target allows differentiating browser support. | 87 * for the same purpose and the target allows differentiating browser support. |
| 88 */ | 88 */ |
| 89 String getEventType(EventTarget target) { | 89 String getEventType(EventTarget target) { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 _target.addEventListener(_eventType, _onData, _useCapture); | 287 _target.addEventListener(_eventType, _onData, _useCapture); |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 | 290 |
| 291 void _unlisten() { | 291 void _unlisten() { |
| 292 if (_onData != null) { | 292 if (_onData != null) { |
| 293 _target.removeEventListener(_eventType, _onData, _useCapture); | 293 _target.removeEventListener(_eventType, _onData, _useCapture); |
| 294 } | 294 } |
| 295 } | 295 } |
| 296 | 296 |
| 297 Future asFuture([var futureValue]) { | 297 Future/*<E>*/ asFuture/*<E>*/([var/*=E*/ futureValue]) { |
| 298 // We just need a future that will never succeed or fail. | 298 // We just need a future that will never succeed or fail. |
| 299 Completer completer = new Completer(); | 299 var completer = new Completer/*<E>*/(); |
| 300 return completer.future; | 300 return completer.future; |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 | 303 |
| 304 /** | 304 /** |
| 305 * A stream of custom events, which enables the user to "fire" (add) their own | 305 * A stream of custom events, which enables the user to "fire" (add) their own |
| 306 * custom events to a stream. | 306 * custom events to a stream. |
| 307 */ | 307 */ |
| 308 abstract class CustomStream<T extends Event> implements Stream<T> { | 308 abstract class CustomStream<T extends Event> implements Stream<T> { |
| 309 /** | 309 /** |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 return new _ElementListEventStreamImpl<T>(e, _eventTypeGetter(e), useCapture
); | 437 return new _ElementListEventStreamImpl<T>(e, _eventTypeGetter(e), useCapture
); |
| 438 } | 438 } |
| 439 | 439 |
| 440 String getEventType(EventTarget target) { | 440 String getEventType(EventTarget target) { |
| 441 return _eventTypeGetter(target); | 441 return _eventTypeGetter(target); |
| 442 } | 442 } |
| 443 | 443 |
| 444 String get _eventType => | 444 String get _eventType => |
| 445 throw new UnsupportedError('Access type through getEventType method.'); | 445 throw new UnsupportedError('Access type through getEventType method.'); |
| 446 } | 446 } |
| OLD | NEW |