我有两个可观察的:
Observable <Profile> profileObservable = briteDatabase.createQuery(UserMapper.Table.NAME, sql, String.valueOf(userId)).mapToOneOrDefault(UserMapper.MAPPER, null);
Observable <List<Car>> carObservable = briteDatabase.createQuery(CarMapper.Table.NAME, sql, String.valueOf(userId)).mapToOneOrDefault(CarMapper.MAPPER, null);
public class Profile {
int id;
String name;
ArrayList<Car> car;
...
}
public class Car {
int id;
String brand;
...
}
我需要从 carObservable 获取汽车列表并将其放入 profileObservable(将汽车列表放入 Profile),内部方法如下:
@Override
public Observable<Profile> getProfile(String userId) {
String sql = String.format("SELECT %s FROM %s WHERE %s=?", TextUtils.join(",", UserMapper.PROJECTION), UserMapper.Table.NAME, UserMapper.Columns.ID);
Observable <Profile> profileObservable = briteDatabase.createQuery(UserMapper.Table.NAME, sql, String.valueOf(userId)).mapToOneOrDefault(UserMapper.MAPPER, null);
Observable <List<Car>> carsObservable = getCars(String userId);
/*
Some important method to concat and return Observable <Profile>. I'm only beginner at RxJava(
*/
}