I\'m working with the Basecamp api to return and display to do lists. Here\'s a sample of what I\'m doing at the moment:
bcxClient
.fetchToDoLists()
.subscri
You should not "break the chain" in your RxJava calls, hence you will need flatMap to chain them. Also Observable.from() lets you split List of elements into separate Observables. Next, you can use toList to get elements back into list. Here's an example :
bcxClient
.fetchToDoLists()
.flatMap(new Func1<List<BcxToDoList>, Observable<BcxToDoList>>() {
@Override
public Observable<BcxToDoList> call(List<BcxToDoList> bcxToDoLists) {
return Observable.from(bcxToDoLists);
}
})
.flatMap(new Func1<BcxToDoList, Observable<List<BcxToDo>>>() {
@Override
public Observable<List<BcxToDo>> call(BcxToDoList bcxToDoList) {
return bcxClient
.fetchToDos(bcxToDoList.bucket.id);
.map(new Func1<List<BcxToDo>, BcxToDoList>() {
@Override
public BcxToDoList call(List<BcxToDo> bcxToDos) {
bcxToDoList.toDos.addAll(bcxToDos);
return bcxToDoList;
}
});
}
})
.toList()
.subscribe(...);