initViews() viewModel.userState.observe(this) { render(it) } } private fun render(state: UserViewState){ when(state) { is UserViewState.loading -> renderLoadingView() is UserViewState.user -> renderUserView(state) is UserViewState.error -> renderErrorView(state) } } private fun renderLoadingView(){ // Code here } private fun renderUserView(userState: UserViewState.user){ // Code here } private fun renderErrorView(errorState: UserViewState.error){ // Code here } WHAT OUR VIEW LOOKS LIKE