I have an observable that emits Timers. I also have an observable that emits Ints. How can I combine them such that an Int will be emitted followed by the timer?
i.e. given an array of ints [1,2,3] and timers [2s, 4s, 3s]
1 (then wait 2 s) 2 (then wait 4 s) 3 (then wait 3 s)
g
Guillermo Alcantara
03/02/2021, 10:57 PM
Can you use
zip
?
g
Grant Park
03/02/2021, 11:06 PM
It seems that zip cannot achieve the example because the BiFunction must wait for both emissions to complete to produce a new type of emission.
Grant Park
03/02/2021, 11:07 PM
It’s really easy to make the following happen:
(wait 2s) emit 1, (wait 4s) emit 2, (wait 3s) emit 3
but I would like the delay to be a post-delay if possible
Grant Park
03/02/2021, 11:29 PM
What seems to be working for me is just mapping the Timers to their values first, and zipping them with the ints to do a blocking sleep or new Timer in a .map or .doOnNext