要建立一个完整的User
实体,我需要执行此任务:从userId
无法建立这种可观察
- 得到一个
UserResponse
(REST API响应)从userId
得到一个
- 获取从
UserResponse.addressId
- 一个
Address
构建从UserResponse
的User
和List<Role>
和Address
。
List<Role>
我尝试这样做:
public Observable<User> getUserById(String userId) {
return Observable.zip(getUserResponse(userId), getRoles(userId), new Func2<UserResponse, List<Role>, User>() {
@Override
public User call(UserResponse response, List<Role> roles) {
//I need the address here!
}
});
但我不知道如何使用AddressRepository
来从UserResponse.addressId
的Address
。
public interface AddressRepository {
Observable<Address> getAddress(String addressId);
}
的User
构造是这样的:
public User(String userId, Address address, List<Role> roles) { ... }
我希望你能理解。很难解释这个问题。
但是你不使用上面的'cache()'操作符 –
Whop,编辑和修复! –