Code Review: ```fun onRefreshTrackCollection() { ...
# compose-desktop
e
Code Review:
Copy code
fun onRefreshTrackCollection() {
    val job = scope.launch {
        refreshTrackCollection()
    }
    when(job.isCompleted) {
        // show snackbar message
    }
}
How do I better execute a UI change when a coroutine job is complete?
l
I would have a StateFlow for isShowingSnackbar (or add it to a data class that holds UI state that is exposed via StateFlow), and have
if(isShowingSnackbar)
in my compose code.
I would also set the variable after
refreshTaskCollection()
inside the
launch
block.
Copy code
fun onRefreshTrackCollection() {
    scope.launch {
        refreshTrackCollection()
        isShowingSnackbarFlow.update { true }
    }
}
e
I'll give that a go