Created
August 11, 2019 08:25
-
-
Save drawers/09501f97c28868c753e2d0afc6cc0c4c to your computer and use it in GitHub Desktop.
Extension method on Observable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T> Observable<T>.debounceIf(predicate: (T) -> Boolean, delay: Long, unit: TimeUnit): Observable<T> { | |
return this.debounce { | |
when { | |
predicate(it) -> Observable.timer(delay, unit) | |
else -> Observable.empty() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment