Skip to content

Instantly share code, notes, and snippets.

@rock3r
Last active June 22, 2018 12:34
Show Gist options
  • Save rock3r/3d63c9508b6bcd875d8f80ed84fd4ed7 to your computer and use it in GitHub Desktop.
Save rock3r/3d63c9508b6bcd875d8f80ed84fd4ed7 to your computer and use it in GitHub Desktop.
RxKotlin's ofType() name is not very easy to remember, given Kotlin has filterIsInstance() for the same. This helps alleviate the pain.
package me.seebrock3r.extensions.reactivex
import io.reactivex.Flowable
import io.reactivex.Observable
import io.reactivex.rxkotlin.ofType
@Deprecated(
message = "This is just a shorthand for RxKotlin's ofType()",
replaceWith = ReplaceWith("ofType<R>()", "io.reactivex.rxkotlin.ofType")
)
inline fun <reified R : Any> Flowable<*>.filterIsInstance(): Flowable<R> = ofType()
@Deprecated(
message = "This is just a shorthand for RxKotlin's ofType()",
replaceWith = ReplaceWith("ofType<R>()", "io.reactivex.rxkotlin.ofType")
)
inline fun <reified R : Any> Observable<*>.filterIsInstance(): Observable<R> = ofType()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment