rx java - Sequence of Retrofits' request where next request depends on result of previous request -


i have sequence of retrofit requests:

observable.interval(0, integer.max_value - 1).concatmap(index -> index == 0 ? getrequesta() : getrequestb()).takeuntil(<condition>) 

request b has parameters must obtain result of request , etc

a -> b(p a.result) -> b1(p b.result) -> bn(p b[n-1].result) 

how can that?

because each event use previous ones, scan operator you're looking for.

the accumulator combined observable "up current event".

here's sample implementation:

    // dummy/sample getrequestb     func1<integer, observable<integer>> getrequestb = -> observable.<integer>create(sub -> { sub.onnext(2*i+1);sub.oncompleted();});      observable.range(0, integer.max_value -1)             .scan(observable.just(0), (acc, rangeidx) -> acc.concatmap(getrequestb::call))             .concatmap(o -> o)             .takeuntil(i -> > 100000)             .subscribe(system.err::println); 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -