Created
June 25, 2020 02:51
-
-
Save ChristopherME/ed18c186f54ea16af54de65b93fac1c2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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