Forked from TrainerGuy22/gist:c6eeddcb6f5205aa3838
Last active
August 29, 2015 14:03
-
-
Save azenla/e590129506942650150c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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