I need to handle multiple button click within short period of time in a way such that I need to get number of click that the user clicked within 500ms
to reduce the number of API calls I make to the backend.
val buttonStream = view.plusButton.clicks()
buttonStream
.buffer(buttonStream.debounce(500, TimeUnit.MILLISECONDS))
.map { it.size }
.subscribe({ clicks ->
Log.i(TAG, "Number of clicks: $clicks")
})
I have implemented the above code but it doesn't display anything when I click the button. When I remove .buffer(buttonStream.debounce(500, TimeUnit.MILLISECONDS))
and just add .buffer(500, TimeUnit.MILLISECONDS)
Log starts printing every 500ms. Is there any way to get my work done?