Skip to content
RED SAGSkills
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)
    }
  }
}
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions