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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 _target.addEventListener(_eventType, _onData, _useCapture); | 291 _target.addEventListener(_eventType, _onData, _useCapture); |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
295 void _unlisten() { | 295 void _unlisten() { |
296 if (_onData != null) { | 296 if (_onData != null) { |
297 _target.removeEventListener(_eventType, _onData, _useCapture); | 297 _target.removeEventListener(_eventType, _onData, _useCapture); |
298 } | 298 } |
299 } | 299 } |
300 | 300 |
301 Future/*<E>*/ asFuture/*<E>*/([var/*=E*/ futureValue]) { | 301 Future<E> asFuture<E>([E futureValue]) { |
302 // We just need a future that will never succeed or fail. | 302 // We just need a future that will never succeed or fail. |
303 var completer = new Completer/*<E>*/(); | 303 var completer = new Completer<E>(); |
304 return completer.future; | 304 return completer.future; |
305 } | 305 } |
306 } | 306 } |
307 | 307 |
308 /** | 308 /** |
309 * A stream of custom events, which enables the user to "fire" (add) their own | 309 * A stream of custom events, which enables the user to "fire" (add) their own |
310 * custom events to a stream. | 310 * custom events to a stream. |
311 */ | 311 */ |
312 abstract class CustomStream<T extends Event> implements Stream<T> { | 312 abstract class CustomStream<T extends Event> implements Stream<T> { |
313 /** | 313 /** |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 e, _eventTypeGetter(e), useCapture); | 438 e, _eventTypeGetter(e), useCapture); |
439 } | 439 } |
440 | 440 |
441 String getEventType(EventTarget target) { | 441 String getEventType(EventTarget target) { |
442 return _eventTypeGetter(target); | 442 return _eventTypeGetter(target); |
443 } | 443 } |
444 | 444 |
445 String get _eventType => | 445 String get _eventType => |
446 throw new UnsupportedError('Access type through getEventType method.'); | 446 throw new UnsupportedError('Access type through getEventType method.'); |
447 } | 447 } |
OLD | NEW |