Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
typical user view model
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