I’ve got the following code (Android):
coroutineScope.launch {
val songs = mutableListOf<Song>()
mediaProvider.findSongs().collect { (song, progress) ->
songs.add(song)
listeners.forEach { listener -> listener.onProgress(progress, song) }
}
listeners.forEach { listener -> listener.onComplete() }
}
The scope is instantiated via
CoroutineScope(Dispatchers.Main)
Despite
listener.onProgress
being called on the main thread - and successful log messages when it is called, the UI updates I’m making in response don’t seem to have any effect.
Are the
listener.onProgress(progress, song)
calls somehow being gathered up and then all executed at the end?
Ooh I think I might be blocking the main thread somewhere