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

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

Issue 1841223002: Fix most strong mode warnings. (Closed) Base URL: git@github.com:dart-lang/async.git@master
Patch Set: Code review changes Created 4 years, 8 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 | « lib/src/result/error.dart ('k') | lib/src/result/value.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 '../delegate/future.dart'; 7 import '../delegate/future.dart';
8 import '../result.dart'; 8 import '../result.dart';
9 9
10 /// A [Future] wrapper that provides synchronous access to the result of the 10 /// A [Future] wrapper that provides synchronous access to the result of the
11 /// wrapped [Future] once it's completed. 11 /// wrapped [Future] once it's completed.
12 class ResultFuture<T> extends DelegatingFuture<T> { 12 class ResultFuture<T> extends DelegatingFuture<T> {
13 /// Whether the future has fired and [result] is available. 13 /// Whether the future has fired and [result] is available.
14 bool get isComplete => result != null; 14 bool get isComplete => result != null;
15 15
16 /// The result of the wrapped [Future], if it's completed. 16 /// The result of the wrapped [Future], if it's completed.
17 /// 17 ///
18 /// If it hasn't completed yet, this will be `null`. 18 /// If it hasn't completed yet, this will be `null`.
19 Result<T> get result => _result; 19 Result<T> get result => _result;
20 Result<T> _result; 20 Result<T> _result;
21 21
22 factory ResultFuture(Future<T> future) { 22 factory ResultFuture(Future<T> future) {
23 var resultFuture; 23 ResultFuture<T> resultFuture;
24 resultFuture = new ResultFuture._(Result.capture(future).then((result) { 24 resultFuture = new ResultFuture._(() async {
25 var result = await Result.capture(future);
25 resultFuture._result = result; 26 resultFuture._result = result;
26 return result.asFuture; 27 return await result.asFuture;
27 })); 28 }());
28 return resultFuture; 29 return resultFuture;
29 } 30 }
30 31
31 ResultFuture._(Future<T> future) 32 ResultFuture._(Future<T> future)
32 : super(future); 33 : super(future);
33 } 34 }
OLDNEW
« no previous file with comments | « lib/src/result/error.dart ('k') | lib/src/result/value.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698