Skip to content

Change type of futures parameter of Future.wait to Iterable<FutureOr<T>>Β #30280

Open
@jakemac53

Description

@jakemac53

Now that we have FutureOr, and more apis are starting to use it, I think it makes sense to take advantage of this in Future.wait if possible (error handling might get weird, not sure).

The main use case is when calling .map on some iterable and calling a function that returns a FutureOr. Today you have to wrap that call in an async method to make sure the type of your iterable is Future<T>, but ideally you wouldn't have to do that.

Ideal:

FutureOr<...> doStuff(input) => ...

Future doLotsOfStuff(Iterable inputs) => Future.wait(inputs.map(doStuff))

Required today (or something similar):

FutureOr<...> doStuff(input) => ...

Future doLotsOfStuff(Iterable<...> inputs) =>
    Future.wait(inputs.map((input) async => doStuff(input)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.core-nlibrary-asynctype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions