I have presenter which calls getShops() method.
Observable<List<Shop>> observable = interactor.getData();
Subscription subscription = observable
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<List<Shop>>() {
@Override
public void onCompleted() {
view.hideProgress();
}
@Override
public void onError(Throwable e) {
super.onError(e);
view.hideProgress();
}
@Override
public void onNext(List<Shop> shops) {
handleShops(shops);
view.onSuccess();
}
});
composite.add(subscription);
In data layer I have Interactor which makes request to server with Retrofit and return List<Shop>
.
@Override
public Observable<List<Shop>> getData() {
return api.getShops(pageNum).map(new Func1<ShopWrapper, List<Shop>>() {
@Override
public List<Shop> call(ShopWrapper wrapper) {
return wrapper.getShops();
}
});
}
The problem is that I need to make multiple identical requests with different page parameter, because server returns N shops per page, and I need collect all shops and then return the Observable<List<Shop>>
to presenter.
I'm new to Reactive programming, maybe there is some operator which allows to do this.
Any help would be appreciated.