Skip to content
Snippets Groups Projects
Commit fe9a5792 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Parent coroutine job in ViewModels

parent 621a7ee5
No related branches found
No related tags found
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment