I need to perform multiple http requests and a database query in order to filter data.
I am usin the zip operator from Rxjava
I did the following to prepare my multiple http requests
List<Observable<List<Picture>>> requests = new ArrayList<>();
for(String id : photoIds) {
requests.add(pictureRepository.searchPicture(id).toObservable());
}
I did the following to prepare my database request
Observable<List<Favourite>> favourites = pictureRepository.getFavourites().toObservable();
I try to create the observable but rxjava is not accepting my code
Observable.zip(
requests, favourites,
new BiFunction<Object[], List<Favourite>, List<FavouritePictures>>() {
@Override
public List<FavouritePictures> apply(Object[] t1, List<Favourite> t2) throws Exception {
return /*here I want to check the favourites and return a list*/;
}
}
);
Is there a way to achieve this? Thanks