future_aggregate 1.0.0 copy "future_aggregate: ^1.0.0" to clipboard
future_aggregate: ^1.0.0 copied to clipboard

A library for waiting on multiple futures, returning a record with results.

Future Aggregate #

A small library to provide a simple-looking way (and type safe) to wait multiple Futures at same time, instead of chainning them.

It works as a multiple type-safe option for Future.wait<T>(), since that option only supports one type.

final (name, age) = await FutureAggregate.duo(getUserName(), getUserAge());

Methods #

  1. FutureAggregate.duo
  2. FutureAggregate.trio
  3. FutureAggregate.quartet
  4. FutureAggregate.quintet
  5. FutureAggregate.sextet
  6. FutureAggregate.septet
  7. FutureAggregate.octet
  8. FutureAggregate.nonet
  9. FutureAggregate.decet

Solved Problem #

In the following code, first will fetch name and then will fetch the age.

final name = await getUserName();
final age = await getUserAge();

Instead we can make it occour concurently with:

final nameFuture = getUserName();
final ageFuture = getUserAge();
final name = await nameFuture;
final age = await ageFuture;

With FutureAggregate we can afford same result with better-lokking code:

final (name, age) = await FutureAggregate.duo(getUserName(), getUserAge());
0
likes
160
points
86
downloads

Publisher

verified publisherdig.dev.br

Weekly Downloads

A library for waiting on multiple futures, returning a record with results.

Repository (GitHub)
View/report issues

Topics

#future #async #concurrency

Documentation

API reference

License

MIT (license)

More

Packages that depend on future_aggregate