android - Call extension function inside java class as any RX operator -
i created extension function,
fun <t> observable<t>.subscribewitherrorhandling(onnext: (t) -> unit ,onerror: ((throwable: throwable) -> unit)? = null): subscription { //doing stuff } in kotlin class, able use no problem in way
observable.subscribewitherrorhandling(...)
now, want use function in java class well. see can call statically :
myextensionfile.subscribewitherrorhandling
but in case, need else since it's middle of rx flow. , part i'm stuck with. possible? or no way java code?
simple answer. no.
explanation - believe that's not possible since mean you're extending observableclass abstract. kotlin extensions add same functionality moving out of inheritance tree , in java in you're pretty stuck inheritance.
so option left extend base observable class , create own implementation of same think unwanted in case. simple solution create new method java can take observable , required logic. or create custom class observable instance instance member , write required methods inside (the standard oops way). code used kotlin java.
edit: believe know still point question.
Comments
Post a Comment