Chromium Code Reviews| Index: lib/src/delegate/future.dart |
| diff --git a/lib/src/delegate/future.dart b/lib/src/delegate/future.dart |
| index bfc075b794d09eda0c35f38a862cedc60090fc18..3f7ea72d335306b96b33c359bfc0942db4608f44 100644 |
| --- a/lib/src/delegate/future.dart |
| +++ b/lib/src/delegate/future.dart |
| @@ -4,6 +4,8 @@ |
| import 'dart:async'; |
| +import '../typed/future.dart'; |
| + |
| /// A wrapper that forwards calls to a [Future]. |
| class DelegatingFuture<T> implements Future<T> { |
| /// The wrapped [Future]. |
| @@ -11,6 +13,15 @@ class DelegatingFuture<T> implements Future<T> { |
| DelegatingFuture(this._future); |
| + /// Creates a wrapper which throws if [future]'s value isn't an instance of |
| + /// `T`. |
| + /// |
| + /// This soundly converts a [Future] to a `Future<T>`, regardless of its |
| + /// original generic type, by asserting that its value is an instance of `T` |
|
floitsch
2016/04/12 20:03:08
The text for this one and the EventSink should be
nweiz
2016/04/12 20:41:19
I think it's pretty different. EventSink doesn't e
|
| + /// whenever it's provided. If it's not, the future throws a [CastError]. |
| + static Future/*<T>*/ typed/*<T>*/(Future future) => |
| + future is Future/*<T>*/ ? future : new TypeSafeFuture/*<T>*/(future); |
| + |
| Stream<T> asStream() => _future.asStream(); |
| Future catchError(Function onError, {bool test(Object error)}) => |
| @@ -21,6 +32,6 @@ class DelegatingFuture<T> implements Future<T> { |
| Future<T> whenComplete(action()) => _future.whenComplete(action); |
| - Future<T> timeout(Duration timeLimit, {void onTimeout()}) => |
|
floitsch
2016/04/12 20:03:08
why this change? The value of `onTimeout()` should
nweiz
2016/04/12 20:41:19
This matches dart:async's declaration. The dart:as
|
| + Future<T> timeout(Duration timeLimit, {onTimeout()}) => |
| _future.timeout(timeLimit, onTimeout: onTimeout); |
| } |