Skip to content

Instantly share code, notes, and snippets.

@TrainerGuy22
Last active August 29, 2015 14:03
Show Gist options
  • Save TrainerGuy22/c6eeddcb6f5205aa3838 to your computer and use it in GitHub Desktop.
Save TrainerGuy22/c6eeddcb6f5205aa3838 to your computer and use it in GitHub Desktop.
part of dartboard;
class FutureGroup {
Completer _completer = new Completer();
List<Future> _futures = <Future>[];
FutureGroup();
bool add(Future future) {
if(!_futures.contains(future)) {
_futures.add(future);
return true;
}
return false;
}
Future wait() {
Future.wait(_futures).then((List result) {
_completer.complete(result);
})..catchError((err) => _completer.completeError(err));
return _completer.future;
}
}
@azenla
Copy link

azenla commented Jun 27, 2014

NOTICE

// LINE 3
List<Future> _futures = new List<Future>();
// SHOULD BE
List<Future> _futures = <Future>[];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment