GeeJoe / Debouncer

A debouncer for a function call base on RxJava

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is this

Sometimes we want to limit the frequency of a certain function call, and this debouncer can do that for us.

How to use

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")

About

A debouncer for a function call base on RxJava


Languages

Language:Kotlin 100.0%