Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alphamikle/0404c2f39b801aa609ad183751f2a71d to your computer and use it in GitHub Desktop.
Save alphamikle/0404c2f39b801aa609ad183751f2a71d to your computer and use it in GitHub Desktop.
Backend method for loading items with isolate
/// Event handler [Events.startLoadingItems]
Future<void> _loadingItems() async {
_items.clear();
for (int i = 0; i < 10; i++) {
_items.addAll(await makeManyRequests(5));
if (i < (10 - 1)) {
/// For all requests except the last one - we send only one event
send(Events.loadingItems);
} else {
/// For the last of 10 requests - send a message with data
send(Events.endLoadingItems, _items);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment