Kotlin Coroutines is the best solution to run async operations in modern Android applications. Why? Lightweight, easy API, high performance and of course structured concurrency.
Livedata.onInactive() Did complete? Start Execution NO Livedata.onActive() Is running? YES Wait for timeout Is running? Cancel Execution NO YES Is active Continue Execution YES
Lifecycle Coroutines Extensions val Lifecycle.coroutineScope: LifecycleCoroutineScope suspend fun Lifecycle.whenCreated(block: suspend CoroutineScope.() "-> T): T
suspend fun Lifecycle.whenStarted(block: suspend CoroutineScope.() "-> T): T
suspend fun Lifecycle.whenResumed(block: suspend CoroutineScope.() "-> T): T