hard20 pts · first answer countskotlin-coroutineserror-handling
Polling loop that ignores cancellation
After the ViewModel is cleared, logs show this loop still logging errors over and over. Why?
viewModelScope.launch {
while (true) {
try {
delay(1000)
poll()
} catch (e: Exception) {
log(e)
}
}
}Discussion 0
Join free to post in the discussion.
Related questions
- launch vs async in coroutinesMobile App Developer
- viewModelScope after the screen closesMobile App Developer
- Blocking file read in a coroutineMobile App Developer
- Collecting a cold Flow twiceMobile App Developer
- One failing request in coroutineScopeMobile App Developer
- try/catch around an async callFull Stack Developer
- One failing widget breaks the dashboardFull Stack Developer
- Returning form validation errorsFull Stack Developer