Created
March 17, 2019 23:51
-
-
Save RBusarow/63b88afd278ca427762f18b9238a2b11 to your computer and use it in GitHub Desktop.
Injecting CoroutineScope into the ViewModel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyViewModel( | |
private val myRepository: MyRepository, | |
coroutineScope: CoroutineScope | |
) : BaseViewModel(coroutineScope) | |
abstract class BaseViewModel( | |
coroutineScope: CoroutineScope | |
) : ViewModel(), CoroutineScope by coroutineScope { | |
override fun onCleared() { | |
cancel() | |
super.onCleared() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment