Skip to content

Instantly share code, notes, and snippets.

@nhphong
Created July 8, 2019 03:22
Show Gist options
  • Save nhphong/13504290b79cfb25ae2af3c99bdb5cf7 to your computer and use it in GitHub Desktop.
Save nhphong/13504290b79cfb25ae2af3c99bdb5cf7 to your computer and use it in GitHub Desktop.
fun <T> Observable<T>.debounceIf(
predicate: (T) -> Boolean,
timeout: Long,
unit: TimeUnit,
scheduler: Scheduler
): Observable<T> {
return Observable.merge(
debounce(timeout, unit, scheduler)
.filter { predicate(it) },
filter { !predicate(it) }
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment