Roman Elizarov
1 min readSep 13, 2018

--

If you want keep your async operations while you Android device is rotating you should launch your coroutines from the scope of your ViewModel. Unlike activities, your ViewModels keep working while device is rotating, so all the coroutines in the context of ViewModel keep running. You ViewModel should have some LiveData for “operation is running” state that you can reset when you receive response or error from your backend.

--

--

Roman Elizarov
Roman Elizarov

Written by Roman Elizarov

Project Lead for the Kotlin Programming Language @JetBrains

Responses (1)