| 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 deprecatedFutureValue(_FutureImpl future) => | 7 deprecatedFutureValue(_FutureImpl future) => |
| 8 future._isComplete ? future._resultOrListeners : null; | 8 future._isComplete ? future._resultOrListeners : null; |
| 9 | 9 |
| 10 | 10 |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 /** The onValue and onError handlers return either a value or a future */ | 317 /** The onValue and onError handlers return either a value or a future */ |
| 318 typedef dynamic _FutureOnValue<T>(T value); | 318 typedef dynamic _FutureOnValue<T>(T value); |
| 319 typedef dynamic _FutureOnError(AsyncError error); | 319 typedef dynamic _FutureOnError(AsyncError error); |
| 320 /** Test used by [Future.catchError] to handle skip some errors. */ | 320 /** Test used by [Future.catchError] to handle skip some errors. */ |
| 321 typedef bool _FutureErrorTest(var error); | 321 typedef bool _FutureErrorTest(var error); |
| 322 /** Used by [WhenFuture]. */ | 322 /** Used by [WhenFuture]. */ |
| 323 typedef void _FutureAction(); | 323 typedef void _FutureAction(); |
| 324 | 324 |
| 325 /** Future returned by [Future.then] with no [:onError:] parameter. */ | 325 /** Future returned by [Future.then] with no [:onError:] parameter. */ |
| 326 class _ThenFuture<S, T> extends _TransformFuture<S, T> { | 326 class _ThenFuture<S, T> extends _TransformFuture<S, T> { |
| 327 final _FutureOnValue<S> _onValue; | 327 // TODO(ahe): Restore type when feature is implemented in dart2js |
| 328 // checked mode. |
| 329 final /* _FutureOnValue<S> */ _onValue; |
| 328 | 330 |
| 329 _ThenFuture(this._onValue); | 331 _ThenFuture(this._onValue); |
| 330 | 332 |
| 331 _sendValue(S value) { | 333 _sendValue(S value) { |
| 332 assert(_onValue != null); | 334 assert(_onValue != null); |
| 333 var result; | 335 var result; |
| 334 try { | 336 try { |
| 335 result = _onValue(value); | 337 result = _onValue(value); |
| 336 } catch (e, s) { | 338 } catch (e, s) { |
| 337 _setError(new AsyncError(e, s)); | 339 _setError(new AsyncError(e, s)); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 Future catchError(function(AsyncError error), {bool test(var error)}) { | 453 Future catchError(function(AsyncError error), {bool test(var error)}) { |
| 452 return _future.catchError(function, test: test); | 454 return _future.catchError(function, test: test); |
| 453 } | 455 } |
| 454 | 456 |
| 455 Future whenComplete(void action()) { | 457 Future whenComplete(void action()) { |
| 456 return _future.whenComplete(action); | 458 return _future.whenComplete(action); |
| 457 } | 459 } |
| 458 | 460 |
| 459 Stream<T> asStream() => new Stream.fromFuture(this); | 461 Stream<T> asStream() => new Stream.fromFuture(this); |
| 460 } | 462 } |
| OLD | NEW |