Skip to content

Instantly share code, notes, and snippets.

@azenla
Forked from TrainerGuy22/gist:c6eeddcb6f5205aa3838
Last active August 29, 2015 14:03
Show Gist options
  • Save azenla/e590129506942650150c to your computer and use it in GitHub Desktop.
Save azenla/e590129506942650150c to your computer and use it in GitHub Desktop.
part of dartboard;
class FutureGroup<E> {
Completer<E> _completer = new Completer<E>();
Set<Future<E>> _futures = new Set<Future<E>>();
bool add(Future<E> future) => _futures.add(future);
Future<List<E>> wait() {
Future.wait(_futures).then((result) => _completer.complete(result))
..catchError((err) => _completer.completeError(err));
return _completer.future;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment