I want to use AndroidRx
debounce
function with delay.
Problem is that first emitted item should not be debounced and should not have any delay, but all other items should be. Is there any easy way to achieve it?
now it looks like this:
publishSubject
.debounce(2, TimeUnit.SECONDS)
.observeOn(uiScheduler)
.subscribe({
onView { onRefreshEvent(it) }
}, {
onView { showError() }
}))
solved it with debounceSelector
publishSubject
.debounce {
if (isFirst(it)) {
Observable.just(it)
} else {
Observable.just(it).delay(2, TimeUnit.SECONDS)
}
}
.observeOn(uiScheduler)
.subscribe({
onView { onRefreshEvent(it) }
}, {
onView { showError() }
}))