| 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 part of dart.async; | 5 part of dart.async; |
| 6 | 6 |
| 7 /** The onValue and onError handlers return either a value or a future */ | 7 /** The onValue and onError handlers return either a value or a future */ |
| 8 typedef dynamic _FutureOnValue<T>(T value); | 8 typedef dynamic _FutureOnValue<T>(T value); |
| 9 /** Test used by [Future.catchError] to handle skip some errors. */ | 9 /** Test used by [Future.catchError] to handle skip some errors. */ |
| 10 typedef bool _FutureErrorTest(var error); | 10 typedef bool _FutureErrorTest(var error); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 bool get _isChained => _state == _CHAINED; | 184 bool get _isChained => _state == _CHAINED; |
| 185 bool get _isComplete => _state >= _VALUE; | 185 bool get _isComplete => _state >= _VALUE; |
| 186 bool get _hasError => _state == _ERROR; | 186 bool get _hasError => _state == _ERROR; |
| 187 | 187 |
| 188 void _setChained(_Future source) { | 188 void _setChained(_Future source) { |
| 189 assert(_mayAddListener); | 189 assert(_mayAddListener); |
| 190 _state = _CHAINED; | 190 _state = _CHAINED; |
| 191 _resultOrListeners = source; | 191 _resultOrListeners = source; |
| 192 } | 192 } |
| 193 | 193 |
| 194 Future then(f(T value), { Function onError }) { | 194 Future/*<S>*/ then/*<S>*/(f(T value), { Function onError }) { |
| 195 Zone currentZone = Zone.current; | 195 Zone currentZone = Zone.current; |
| 196 if (!identical(currentZone, _ROOT_ZONE)) { | 196 if (!identical(currentZone, _ROOT_ZONE)) { |
| 197 f = currentZone.registerUnaryCallback(f); | 197 f = currentZone.registerUnaryCallback(f); |
| 198 if (onError != null) { | 198 if (onError != null) { |
| 199 onError = _registerErrorHandler(onError, currentZone); | 199 onError = _registerErrorHandler(onError, currentZone); |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 return _thenNoZoneRegistration(f, onError); | 202 return _thenNoZoneRegistration(f, onError); |
| 203 } | 203 } |
| 204 | 204 |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 } | 709 } |
| 710 }, onError: (e, s) { | 710 }, onError: (e, s) { |
| 711 if (timer.isActive) { | 711 if (timer.isActive) { |
| 712 timer.cancel(); | 712 timer.cancel(); |
| 713 result._completeError(e, s); | 713 result._completeError(e, s); |
| 714 } | 714 } |
| 715 }); | 715 }); |
| 716 return result; | 716 return result; |
| 717 } | 717 } |
| 718 } | 718 } |
| OLD | NEW |