Observable<Collection> request1=... Observable<Collection> request2=... .doOnNext(collection->{ boolean isFull = collection.isFull(); }; Observable.concat(request1, request2); 

The difficulty is that, based on the isFull flag in request2 it is necessary to repeat the execution of the call chains of request1 and request2 . That is, if isFull = false , then re-execute request1 , and then request2 , so 5 times, if for the 5th time isFull = false , then throw error .

  • Well, arrange a cycle with appropriate exit conditions. What exactly is the problem? - Streletz

1 answer 1

If I understand correctly how repeatWhen works, then something like this:

 Observable.concat(request1, request2) .repeatWhen(completed -> collection.isFull() ? Observable.error(error) : completed);