I have a problem with my RxJava callchain. The toList is not working properly. I would guess that it is that the toList() needs something to complete. That is why it is stuck. But i do not know how to solve this issue
The code
mModel.getLocations()
.flatMapIterable(new Function<List<Location>, List<Location>>(){
@Override
public List<Location> apply(final List<Location> locations) throws Exception {
return locations;
}
})
.filter(new Predicate<Location>() {
@Override
public boolean test(final Location location) throws Exception {
return location.searchExistInNameOrKeyWord(input);
}
})
.toList()
.map(new Function<List<Location>, List<Location>>() {
@Override
public List<Location> apply(List<Location> locations) throws Exception {
/** Doing some random work with the list and then returning */
}
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<List<Location>>() {
@Override
public void accept(final List<Location> locations) throws Exception {
mView.setAdapterItems(locations);
}
});
Maybe someone that is a lot better than me at RxJava could pinpoint what i am doing wrong.
Update
@Query("SELECT * from location")
Flowable<List<Location>> loadAllLocations();
The mModel.getLocations()
just calls the loadAllLocations like above from the Room percistance storage