Created
May 29, 2019 08:57
-
-
Save lucanicoletti/d5a8c2f9089f395c7e3ebe4cf5238bab to your computer and use it in GitHub Desktop.
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 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