OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library android_extension; | 5 library android_extension; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 | 7 |
8 // A VERY simplified DOM. | 8 // A VERY simplified DOM. |
9 | 9 |
10 class BodyElement { | 10 class BodyElement { |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 throw new StateError("Subscription has been canceled."); | 207 throw new StateError("Subscription has been canceled."); |
208 } | 208 } |
209 // Remove current event listener. | 209 // Remove current event listener. |
210 _unlisten(); | 210 _unlisten(); |
211 | 211 |
212 _onData = handleData | 212 _onData = handleData |
213 _tryResume(); | 213 _tryResume(); |
214 } | 214 } |
215 | 215 |
216 /// Has no effect. | 216 /// Has no effect. |
217 void onError(void handleError(AsyncError error)) {} | 217 void onError(void handleError(Object error)) {} |
218 | 218 |
219 /// Has no effect. | 219 /// Has no effect. |
220 void onDone(void handleDone()) {} | 220 void onDone(void handleDone()) {} |
221 | 221 |
222 void pause([Future resumeSignal]) { | 222 void pause([Future resumeSignal]) { |
223 if (_canceled) { | 223 if (_canceled) { |
224 throw new StateError("Subscription has been canceled."); | 224 throw new StateError("Subscription has been canceled."); |
225 } | 225 } |
226 ++_pauseCount; | 226 ++_pauseCount; |
227 _unlisten(); | 227 _unlisten(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 final Object _target; | 267 final Object _target; |
268 final String _eventType; | 268 final String _eventType; |
269 | 269 |
270 _EventStream(this._target, this._eventType); | 270 _EventStream(this._target, this._eventType); |
271 | 271 |
272 // DOM events are inherently multi-subscribers. | 272 // DOM events are inherently multi-subscribers. |
273 Stream<T> asBroadcastStream() => this; | 273 Stream<T> asBroadcastStream() => this; |
274 bool get isBroadcast => true; | 274 bool get isBroadcast => true; |
275 | 275 |
276 StreamSubscription<T> listen(void onData(T event), | 276 StreamSubscription<T> listen(void onData(T event), |
277 { void onError(AsyncError error), | 277 { void onError(Object error), |
278 void onDone(), | 278 void onDone(), |
279 bool unsubscribeOnError}) { | 279 bool unsubscribeOnError}) { |
280 | 280 |
281 return new _EventStreamSubscription<T>( | 281 return new _EventStreamSubscription<T>( |
282 this._target, this._eventType, onData); | 282 this._target, this._eventType, onData); |
283 } | 283 } |
284 } | 284 } |
285 | 285 |
286 class Node extends EventTarget { | 286 class Node extends EventTarget { |
287 Stream<KeyboardEvent> get onKeyDown => new _EventStream(this, 'keydown'); | 287 Stream<KeyboardEvent> get onKeyDown => new _EventStream(this, 'keydown'); |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 | 1202 |
1203 // TODO(vsm): Kill. | 1203 // TODO(vsm): Kill. |
1204 noSuchMethod(invocation) { | 1204 noSuchMethod(invocation) { |
1205 throw new Exception('Unimplemented/unknown ${invocation.memberName}'); | 1205 throw new Exception('Unimplemented/unknown ${invocation.memberName}'); |
1206 } | 1206 } |
1207 } | 1207 } |
1208 | 1208 |
1209 var sfx_extension = 'raw'; | 1209 var sfx_extension = 'raw'; |
1210 int _loadSample(String s) native "LoadSample"; | 1210 int _loadSample(String s) native "LoadSample"; |
1211 int _playSample(String s) native "PlaySample"; | 1211 int _playSample(String s) native "PlaySample"; |
OLD | NEW |