我的RxJava callchain出現問題。 toList工作不正常。我想這是toList()需要完成的東西。這就是它被卡住的原因。但我不知道如何解決這個問題Rxjava tolist()未完成
代碼
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);
}
});
也許有人比我好很多,在RxJava可以查到我在做什麼錯。
更新
@Query("SELECT * from location")
Flowable<List<Location>> loadAllLocations();
的mModel.getLocations()
只是調用上面一樣從房percistance存儲
那麼,是'mModel.getLocations()'實際上完成? –
在帖子中增加了更多信息。它唯一做的就是從存儲中調用loadAllLocations –