Sometimes we want to limit the frequency of a certain function call, and this debouncer can do that for us.
1、The function to be debounce
fun test(s: String) {
println(s)
}
2、Create a Debouncer with a timeout in 1 second
val debouncer = Debouncer.create<String>({ str ->
test(str)
}, 1, TimeUnit.SECONDS, AndroidSchedulers.mainThread())
3、Invoke the function via debouncer like this
debouncer.onNext("Hello world")