Skip to content

Instantly share code, notes, and snippets.

@prokash-sarkar
Last active November 7, 2019 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prokash-sarkar/f412f339025e0f8c60c41e2bc62c05f6 to your computer and use it in GitHub Desktop.
Save prokash-sarkar/f412f339025e0f8c60c41e2bc62c05f6 to your computer and use it in GitHub Desktop.
BaseViewModel
abstract class BaseViewModel: ViewModel()
{
protected val _viewState: MutableLiveData<ViewState> = MutableLiveData()
// don't expose the MutableLiveData outside of the class
val viewState: LiveData<ViewState>
get() = _viewState // only getter / no setter
fun setViewState(viewState: ViewState){
_viewState.value = viewState
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment