Index: sdk/lib/async/future.dart |
diff --git a/sdk/lib/async/future.dart b/sdk/lib/async/future.dart |
index 7d892c687ef1cd0197b149b65a173d56dcc6f3a5..283e4b48887a81fddc379cc4ecc0eab4c4171137 100644 |
--- a/sdk/lib/async/future.dart |
+++ b/sdk/lib/async/future.dart |
@@ -4,6 +4,37 @@ |
part of dart.async; |
+/// The union of `Future<T>` and `T`. |
Lasse Reichstein Nielsen
2016/12/08 15:14:00
I would save the "union" word to the advanced sect
floitsch
2016/12/08 16:23:59
That wording doesn't work for me. If read the wron
|
+/// |
+/// This is a magic class that is recognized by the Dart tools. It is |
Lasse Reichstein Nielsen
2016/12/08 15:14:00
I wouldn't actually use the word "magic" in writin
floitsch
2016/12/08 16:23:59
Changed. PTAL.
|
+/// used in places where functions accept or return a `Future<T>` or a `T`. |
+/// |
+/// This class can not be implemented or extended. |
Lasse Reichstein Nielsen
2016/12/08 15:14:00
or mixed in.
The spec language is (e.g.):
Brian Wilkerson
2016/12/08 15:25:46
nit: "can not" --> "cannot"
nit: or mixed in? (may
floitsch
2016/12/08 16:23:59
Done.
|
+/// |
+/// Note: the `FutureOr<T>` type is interpreted as `dynamic` in non strong-mode. |
+/// |
+/// # Examples |
+/// ``` dart |
+/// // The `Future<T>.then` function takes a callback [f] that returns either |
+/// // an `S` or a `Future<S>`. |
+/// Future<S> then<S>(FutureOr<S> f(T x), ...); |
+/// |
+/// // `Completer<T>.complete` takes either a `T` or `Future<T>`. |
+/// void complete(FutureOr<T> value); |
+/// ``` |
+/// |
+/// # Advanced |
+/// Since `FutureOr<Object>` is the union of `Future<Object>` and `Object`, it |
Lasse Reichstein Nielsen
2016/12/08 15:14:00
"the union" isn't defined anywhere, so it's not cl
floitsch
2016/12/08 16:23:59
Done.
|
+/// is equivalent to `Object`, because `Future<Object>` is a subtype of |
+/// `Object`. |
+/// |
+/// As a corollary, `FutureOr<Object>` is equivalent to |
+/// `FutureOr<FutureOr<Object>>`. |
Lasse Reichstein Nielsen
2016/12/08 15:14:00
(and equivalent to Object)
The more interesting e
floitsch
2016/12/08 16:23:59
Done.
|
+class FutureOr<T> { |
+ // Private constructor, so that it is not subclassable and instantiable. |
Lasse Reichstein Nielsen
2016/12/08 15:14:00
or mixin'able, as if that was a word.
For even mo
floitsch
2016/12/08 16:23:59
Done.
|
+ FutureOr._(); |
+} |
+ |
/** |
* An object representing a delayed computation. |
* |