Skip to content

Instantly share code, notes, and snippets.

@ChristopherME
Created June 25, 2020 02:51
Show Gist options
  • Save ChristopherME/ed18c186f54ea16af54de65b93fac1c2 to your computer and use it in GitHub Desktop.
Save ChristopherME/ed18c186f54ea16af54de65b93fac1c2 to your computer and use it in GitHub Desktop.
class SomeViewModel(private val getUserUseCase: GetUserUseCase) : ViewModel() {
// Only your viewmodel should update the value.
private val _user: MutableLiveData<User> = MutableLiveData()
val userName: LiveData<String> = _user.map {
resultUser -> "${resultUser.name} + ${resultUser.lastName}"
}
...
private fun executeUseCase() {
_user.value = getUserUseCase.someComputation()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment