Created
June 25, 2020 03:26
-
-
Save ChristopherME/f507aefe8a09145b0822de5c2c55da85 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 SomeViewModel( | |
private val getUsersUseCase: GetUserUseCase, | |
private val mapper: PresentationMapper | |
) : ViewModel() { | |
// Only your viewmodel should update the value. | |
private val _users: MutableLiveData<List<PresentationUser>> = MutableLiveData() | |
val users: LiveData<List<PresentationUser>> | |
get() = _users | |
... | |
private fun executeUseCase() { | |
viewModelScope.launch { | |
val domainUsers = getUserUseCase.someComputation() | |
val presentationUsers = mapper.mapDomainUsersToPresentation(domainUsers) | |
_users.value = presentationUsers | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment