Simon Kågedal Reimer
12/10/2019, 3:12 PMFlowable and I would like to consume all events from it, but add a little delay between each events. How would I best do that?Simon Kågedal Reimer
12/10/2019, 3:19 PMtheFlowable.concatMap(s -> Flowable.just(s).delay(1, TimeUnit.SECONDS))kioba
12/10/2019, 4:15 PMtheFlowable.delay(1, TimeUnit.SECONDS)Simon Kågedal Reimer
12/10/2019, 5:57 PMFlowable.just("One", "two", "three")
.delay(1, TimeUnit.SECONDS)
.subscribe(System.out::println);
I’m getting a one second delay, then all three printing at the same time. This, however:
Flowable.just("One", "two", "three")
.concatMap(f -> Flowable.just(f).delay(1, TimeUnit.SECONDS))
.subscribe(System.out::println);
..gives me one second pause, “One”, one second pause, “two”, one second pause, “three” – which is what I want.alexsullivan114
12/10/2019, 6:09 PMdelay that works the way you'd expect it to but in general I think you've got the right approach.
You could also zip your flowable with Flowable.interval to effectively pair up each item in your stream with the item emitted by interval.
Six to half a dozen though reallySimon Kågedal Reimer
12/10/2019, 7:05 PMkioba
12/10/2019, 8:18 PMconcatMap with a delay is a nice solution!