0

I'm new to Rxjava and could not find an example or appropriate usage of single.delay() that uses the result of the previous flatmap as the delay. My aim is to use the result of functionOne() to set the delay dynamically.

.flatMap(o -> functionOne(para),Pair::new) .flatMap(pair -> Single.delay(pair.first, TimeUnit.millis)) .doOnSuccess(o -> funcitonTwo(driver, pair.two)) 

I'm really shooting in the dark but some things I gave a try where; delaySubscription, retryWhen, replayWhen,

I could not get these examples to work.

1 Answer 1

0

Delay is for in-sequence delaying. There are a couple of ways for doing this. Given your funcitonTwo usage, you'll probably need this:

.flatMap(o -> functionOne(para), Pair::new) .flatMap(pair -> Single.just(pair).delay(pair.first, TimeUnit.millis)) .doOnSuccess(pair -> funcitonTwo(driver, pair.two)) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.