Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: lib/src/delegate/future.dart

Issue 2161283002: Fix Dart 1.17 strong-mode warnings. (Closed) Base URL: git@github.com:dart-lang/async.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/delegate/stream_subscription.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import '../typed/future.dart'; 7 import '../typed/future.dart';
8 8
9 /// A wrapper that forwards calls to a [Future]. 9 /// A wrapper that forwards calls to a [Future].
10 class DelegatingFuture<T> implements Future<T> { 10 class DelegatingFuture<T> implements Future<T> {
11 /// The wrapped [Future]. 11 /// The wrapped [Future].
12 final Future<T> _future; 12 final Future<T> _future;
13 13
14 DelegatingFuture(this._future); 14 DelegatingFuture(this._future);
15 15
16 /// Creates a wrapper which throws if [future]'s value isn't an instance of 16 /// Creates a wrapper which throws if [future]'s value isn't an instance of
17 /// `T`. 17 /// `T`.
18 /// 18 ///
19 /// This soundly converts a [Future] to a `Future<T>`, regardless of its 19 /// This soundly converts a [Future] to a `Future<T>`, regardless of its
20 /// original generic type, by asserting that its value is an instance of `T` 20 /// original generic type, by asserting that its value is an instance of `T`
21 /// whenever it's provided. If it's not, the future throws a [CastError]. 21 /// whenever it's provided. If it's not, the future throws a [CastError].
22 static Future/*<T>*/ typed/*<T>*/(Future future) => 22 static Future/*<T>*/ typed/*<T>*/(Future future) =>
23 future is Future/*<T>*/ ? future : new TypeSafeFuture/*<T>*/(future); 23 future is Future/*<T>*/ ? future : new TypeSafeFuture/*<T>*/(future);
24 24
25 Stream<T> asStream() => _future.asStream(); 25 Stream<T> asStream() => _future.asStream();
26 26
27 Future catchError(Function onError, {bool test(Object error)}) => 27 Future<T> catchError(Function onError, {bool test(Object error)}) =>
28 _future.catchError(onError, test: test); 28 _future.catchError(onError, test: test);
29 29
30 Future/*<S>*/ then/*<S>*/(/*=S*/ onValue(T value), {Function onError}) => 30 Future/*<S>*/ then/*<S>*/(/*=S*/ onValue(T value), {Function onError}) =>
31 _future.then(onValue, onError: onError); 31 _future.then(onValue, onError: onError);
32 32
33 Future<T> whenComplete(action()) => _future.whenComplete(action); 33 Future<T> whenComplete(action()) => _future.whenComplete(action);
34 34
35 Future<T> timeout(Duration timeLimit, {onTimeout()}) => 35 Future<T> timeout(Duration timeLimit, {onTimeout()}) =>
36 _future.timeout(timeLimit, onTimeout: onTimeout); 36 _future.timeout(timeLimit, onTimeout: onTimeout);
37 } 37 }
OLDNEW
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/delegate/stream_subscription.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698