Last active
November 21, 2019 11:44
-
-
Save ATizik/08605472c00639d771a71ca3aa202922 to your computer and use it in GitHub Desktop.
Exposing superclass without backing property
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
import androidx.fragment.app.Fragment | |
import androidx.fragment.app.viewModels | |
import androidx.lifecycle.* | |
interface MyViewModelInterface { | |
val liveData: LiveData<String> | |
} | |
class MyViewModel:ViewModel(), MyViewModelInterface { | |
override val liveData = MutableLiveData<String>() | |
} | |
class MyFragment:Fragment() { | |
val viewModel:MyViewModelInterface by viewModels<MyViewModel>() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment