I want to create an observable that emits values every 5 seconds (0s, 5s, 10s, etc) and when I used Observable.interval(5, TimeUnit.SECONDS)
there's 5 seconds delay before emitting the very first event and when I googled and tried to use Observable.timer
I was confused by its Scheduler scheduler
parameter.
My current workaround (after I found the answers to some similar question) is to add .startsWith(0L)
:
Observable.interval(5, TimeUnit.SECONDS).startsWith(0L)
Is there an operator that accepts delay (or takes 0 by default) and where I can specify an interval?