-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit 9f70bc7
Add
There is currently no way to create a future with a specific value
that doesn't accept a `FutureOr` argument, and tries to flatten it.
The `Future.syncValue(T value)` constructor does not accept a
`Future<T>`, which makes it easier to control the type and argument.
It may also be more efficient than constructors which need to first
check if the argument is a `Future<T>` (and `_Future<T>`) first.
You shouldn't create a `Future<Future<Object>>`, but you might for
testing, and this constructor makes that easier too.
(It should really be called `Future.value`, but that name was taken
by what should probably have been `Future.new`.)
See https://dartbug.com/59814 for performance considerations.
CoreLibraryReviewExempt: No platform specific code or new functionality.
Change-Id: Ib5728055a06b20433dcd448ca7ad1baa54ec681c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/451022
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>Future.syncValue(T value) constructor.1 parent 4f8af89 commit 9f70bc7
File tree
3 files changed
+181
-125
lines changed- sdk/lib/async
- tests/lib/async
3 files changed
+181
-125
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | + | ||
94 | + | ||
95 | + | ||
96 | + | ||
97 | + | ||
98 | + | ||
93 | 99 | | |
94 | 100 | | |
95 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | - | ||
298 | - | ||
297 | + | ||
299 | 298 | | |
300 | - | ||
301 | - | ||
299 | + | ||
300 | + | ||
301 | + | ||
302 | + | ||
303 | + | ||
304 | + | ||
302 | 305 | | |
303 | 306 | | |
304 | 307 | | |
305 | - | ||
306 | - | ||
308 | + | ||
309 | + | ||
307 | 310 | | |
308 | 311 | | |
309 | 312 | | |
310 | - | ||
313 | + | ||
314 | + | ||
315 | + | ||
316 | + | ||
317 | + | ||
311 | 318 | | |
319 | + | ||
320 | + | ||
321 | + | ||
312 | 322 | | |
313 | 323 | | |
314 | 324 | | |
| |||
320 | 330 | | |
321 | 331 | | |
322 | 332 | | |
333 | + | ||
334 | + | ||
335 | + | ||
336 | + | ||
337 | + | ||
338 | + | ||
339 | + | ||
340 | + | ||
341 | + | ||
342 | + | ||
343 | + | ||
323 | 344 | | |
324 | 345 | | |
325 | 346 | | |
| |||
0 commit comments