Hi everyone, I’m new with Rx. Can anyone help to u...
# rx
a
Hi everyone, I’m new with Rx. Can anyone help to understand
requestData()
is called twice and how to avoid it?
Copy code
Observable.just(Unit)
                .delay(REPEAT_DELAY, TimeUnit.MILLISECONDS)
                .repeat()
                .async(job)
                .subscribe({ requestData() },
                        {
                            Timber.e(it, "subscribeError")
                        }
                )
t
Where does the
async
function comes from ? I can't resolve it.
a
custom Kotlin extension but thank you. Observe on Schedulers.io() and subscribe on Schedulers.io(). Same thing for asyncUI
but the latter one observe on main thread
t
Your problem is due to the
repeat
operator : it will re-emit the same
Unit
undefinitely, every
REPEAT_DELAY
. Maybe you could tell us more about what you want to achieve ?
a
It’s solved. Noob thing. Sorry. Anyway, the repeat is intentional and that’s the expected behavior. The problem was the requestData() to be called twice every time the repeat was executed and not that it repeats per every desired amount of time.