Created
January 31, 2021 14:00
-
-
Save alphamikle/6399429fe986c28c89d22cfe4d350301 to your computer and use it in GitHub Desktop.
Search with isolate backend
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
/// Handler for event [Events.cacheItems] | |
void _cacheItems() { | |
_notFilteredItems.clear(); | |
final List<Item> multipliedItems = []; | |
for (int i = 0; i < 10; i++) { | |
multipliedItems.addAll(_items); | |
} | |
_notFilteredItems.addAll(multipliedItems); | |
send(Events.cacheItems); | |
} | |
/// For each event [Events.startSearch] this method is called, | |
/// filtering elements and sending the filtered to the light state | |
void _filterItems(String searchValue) { | |
if (searchValue.isEmpty) { | |
_items.clear(); | |
_items.addAll(_notFilteredItems); | |
send(ThirdEvents.setFilteredItems, _items); | |
return; | |
} | |
final List<Item> filteredItems = filterItems(Packet2(_notFilteredItems, searchValue)); | |
_items.clear(); | |
_items.addAll(filteredItems); | |
send(Events.setFilteredItems, _items); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment