Skip to content

Instantly share code, notes, and snippets.

@hadilq
Created November 5, 2018 17:54
Show Gist options
  • Save hadilq/7a3246fb774152a6adcc364006b5b502 to your computer and use it in GitHub Desktop.
Save hadilq/7a3246fb774152a6adcc364006b5b502 to your computer and use it in GitHub Desktop.
inline fun <T, reified E : T> Observable<in T>.filterTo(
@Suppress("UNUSED_PARAMETER") target: Class<E>
): Observable<out E> = this.filter {
when (it) {
is E -> true
else -> false
}
}.map { it as E }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment