Created
January 31, 2021 13:54
-
-
Save alphamikle/0404c2f39b801aa609ad183751f2a71d to your computer and use it in GitHub Desktop.
Backend method for loading items with isolate
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
/// 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