Last active
July 3, 2020 14:47
-
-
Save tobioyelekan/0e689d1f0f89fcfc7be1b306114522c4 to your computer and use it in GitHub Desktop.
typical user view model
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
private val userId = MutableLiveData<String>() | |
val userDetails = userId.switchMap { | |
userRepo.getUser(it) | |
} | |
val userFullName = userDetails.map { | |
getFullName(it.firstName, it.lastName) | |
} | |
fun setUserId(userId: String) { | |
this.userId.value = userId | |
} | |
fun getFullName(firstName: String, lastName: String) = "$firstName $lastName" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment