OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer.src.cancelable_future; | 5 library analyzer.src.cancelable_future; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 /** | 9 /** |
10 * Type of callback called when the future returned by a CancelableCompleter | 10 * Type of callback called when the future returned by a CancelableCompleter |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 @override | 245 @override |
246 void cancel() { | 246 void cancel() { |
247 _completer._cancel(); | 247 _completer._cancel(); |
248 } | 248 } |
249 | 249 |
250 @override | 250 @override |
251 Future<T> catchError(Function onError, {bool test(Object error)}) => | 251 Future<T> catchError(Function onError, {bool test(Object error)}) => |
252 _completer._outerCompleter.future.catchError(onError, test: test); | 252 _completer._outerCompleter.future.catchError(onError, test: test); |
253 | 253 |
254 @override | 254 @override |
255 Future/*<S>*/ then/*<S>*/(FutureOr/*<S>*/ onValue(T value), | 255 Future<S> then<S>(FutureOr<S> onValue(T value), {Function onError}) => |
256 {Function onError}) => | |
257 _completer._outerCompleter.future.then(onValue, onError: onError); | 256 _completer._outerCompleter.future.then(onValue, onError: onError); |
258 | 257 |
259 @override | 258 @override |
260 Future<T> timeout(Duration timeLimit, {onTimeout()}) { | 259 Future<T> timeout(Duration timeLimit, {onTimeout()}) { |
261 // TODO(paulberry): Implement this in such a way that a timeout cancels | 260 // TODO(paulberry): Implement this in such a way that a timeout cancels |
262 // the future. | 261 // the future. |
263 return _completer._outerCompleter.future | 262 return _completer._outerCompleter.future |
264 .timeout(timeLimit, onTimeout: onTimeout); | 263 .timeout(timeLimit, onTimeout: onTimeout); |
265 } | 264 } |
266 | 265 |
(...skipping 15 matching lines...) Expand all Loading... |
282 Stream<T> asStream() => _future.asStream(); | 281 Stream<T> asStream() => _future.asStream(); |
283 | 282 |
284 @override | 283 @override |
285 void cancel() {} | 284 void cancel() {} |
286 | 285 |
287 @override | 286 @override |
288 Future<T> catchError(Function onError, {bool test(Object error)}) => | 287 Future<T> catchError(Function onError, {bool test(Object error)}) => |
289 _future.catchError(onError, test: test); | 288 _future.catchError(onError, test: test); |
290 | 289 |
291 @override | 290 @override |
292 Future/*<S>*/ then/*<S>*/(FutureOr/*<S>*/ onValue(T value), | 291 Future<S> then<S>(FutureOr<S> onValue(T value), {Function onError}) => |
293 {Function onError}) => | |
294 _future.then(onValue, onError: onError); | 292 _future.then(onValue, onError: onError); |
295 | 293 |
296 @override | 294 @override |
297 Future<T> timeout(Duration timeLimit, {onTimeout()}) => | 295 Future<T> timeout(Duration timeLimit, {onTimeout()}) => |
298 _future.timeout(timeLimit, onTimeout: onTimeout); | 296 _future.timeout(timeLimit, onTimeout: onTimeout); |
299 | 297 |
300 @override | 298 @override |
301 Future<T> whenComplete(action()) => _future.whenComplete(action); | 299 Future<T> whenComplete(action()) => _future.whenComplete(action); |
302 } | 300 } |
OLD | NEW |