-
-
Save azenla/4edc243dfada8b9e0fad 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
class FutureGroup { | |
Completer _completer = new Completer(); | |
List<Future> _futures = new List<Future>(); | |
FutureGroup(); | |
bool add(Future future) { | |
if(!_futures.contains(future)) { | |
_futures.add(future); | |
return true; | |
} | |
return false; | |
} | |
Future wait() { | |
Future.wait(_futures).then((result) { | |
_completer.complete(); | |
})..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