Skip to content

Instantly share code, notes, and snippets.

@lucanicoletti
Created May 29, 2019 08:57
Show Gist options
  • Save lucanicoletti/d5a8c2f9089f395c7e3ebe4cf5238bab to your computer and use it in GitHub Desktop.
Save lucanicoletti/d5a8c2f9089f395c7e3ebe4cf5238bab to your computer and use it in GitHub Desktop.
class MyActivity: Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setupViewModel()
}
private fun setupViewModel() {
viewModel = //factory fancy way to get the instance of ViewModel
viewModel.viewState.observe(this, Observer {
when (it) {
MVIViewState.Loading -> { // show loading
}
MVIViewState.Error -> { // display error message
}
MVIViewState.Success -> { // show data fetched
}
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment