Commit fe9a5792 authored by Geoffrey Métais's avatar Geoffrey Métais

Parent coroutine job in ViewModels

parent 621a7ee5
......@@ -3,9 +3,16 @@ package org.videolan.vlc.viewmodels
import android.arch.lifecycle.ViewModel
import kotlinx.coroutines.experimental.CoroutineScope
import kotlinx.coroutines.experimental.Dispatchers
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.android.Main
open class ScopedModel : ViewModel(), CoroutineScope {
override val coroutineContext = Dispatchers.Main.immediate
protected val job = Job()
override val coroutineContext = Dispatchers.Main.immediate+job
override fun onCleared() {
super.onCleared()
job.cancel()
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment