'Android doing too much work on its main thread when collecting Flow
I have a local database function that returns the list of users in Flow format. Flow<List<User>>. The home screen only displays the latest list of users. When launching the app and pre-populating the database the flow receives the empty list first and then the updated list as the pre-population completes.
This is causing the Android to do too much work on its main thread and skipping the frames to render.
viewModelScope.launch {
dao.getUsers().collect {
userList.value = it
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
