OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 import 'dart:async'; |
| 6 |
| 7 class TypeSafeFuture<T> implements Future<T> { |
| 8 final Future _future; |
| 9 |
| 10 TypeSafeFuture(this._future); |
| 11 |
| 12 Stream<T> asStream() => _future.then((value) => value as T).asStream(); |
| 13 |
| 14 Future catchError(Function onError, {bool test(Object error)}) => |
| 15 _future.catchError(onError, test: test); |
| 16 |
| 17 Future/*<S>*/ then/*<S>*/(/*=S*/ onValue(T value), {Function onError}) => |
| 18 _future.then((value) => onValue(value as T), onError: onError); |
| 19 |
| 20 Future<T> whenComplete(action()) => |
| 21 new TypeSafeFuture<T>(_future.whenComplete(action)); |
| 22 |
| 23 Future<T> timeout(Duration timeLimit, {onTimeout()}) => |
| 24 new TypeSafeFuture<T>(_future.timeout(timeLimit, onTimeout: onTimeout)); |
| 25 } |
OLD | NEW |