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());

Libraries

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