In map()function
LiveData userLiveData = ...;
LiveData userName = Transformations.map(userLiveData, user -> {
return user.firstName + " " + user.lastName;
});
, userLiveData , userName . , String.
switchMap():
MutableLiveData userIdLiveData = ...;
LiveData userLiveData = Transformations.switchMap(userIdLiveData, id ->
repository.getUserById(id));
void setUserId(String userId) {
this.userIdLiveData.setValue(userId);
}
userIdLiveData , userIdLiveData , repository.getUserById(id), map. repository.getUserById(id) LiveData. , LiveData repository.getUserById(id) , userLiveData . , userLiveData userIdLiveData repository.getUserById(id).
switchMap(): , "" " ", . setUserId() , userLiveData . Follow DAO, , 301 300. userLiveData , , DAO.