-1

i'm currently trying to poll multiple endpoints (which are different) the problem is i want to keep polling only the endpoints which didn't return the status i need in an aggregated manner so the flow is basically :

build the requests -> merge them to one stream -> poll for response -> check is status matches :

  1. if doesn't wait and redo the flow
  2. if does take the observer out of the stream

this is what i have written and it feels like i'm missing something

Observable.merge(buildRequests())
.repeatWhen(obs -> obs.delay(5000, TimeUnit.MILLISECONDS))
.takeUntil(response -> CheckShouldRepeat(response)).subscribe(whatever());

thanks a bunch!

VodkaPlease
  • 31
  • 1
  • 5

1 Answers1

0
Observable.fromCallable(() -> buildRequests())
.repeatWhen(o -> CheckShouldRepeat(v -> Observable.timer(5000, TimeUnit.MILLISECONDS)));

This can help.

Ankit Kumar
  • 3,663
  • 2
  • 26
  • 38