RxGroovy icon indicating copy to clipboard operation
RxGroovy copied to clipboard

newbie - is this compatible with RxJava 2.0

Open amiracam opened this issue 7 years ago • 3 comments

i.e. does it support Flowable api ? thanks

amiracam avatar Nov 10 '17 16:11 amiracam

Hi. No and the project is practically dead.

akarnokd avatar Nov 10 '17 16:11 akarnokd

great, so jus use RxJava from groovy I guess

amiracam avatar Nov 10 '17 17:11 amiracam

@amiracam that works, but... you have to watch out for overloaded methods that that have both closure compatible and non-closure compatible arguments. For example onErrorResumeNext. All variants of this accept either the source to resume to or a Function which produces the source. Now, if that Function were of the Java 8 variety then Groovy's standard closure conversion would work its magic and all would be well. But since Function here is the RxJava2 defined class (and isn't explicitly declared as a functional interface) Groovy doesn't know what to do and you get:

Caused by: groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method io.reactivex.internal.operators.maybe.MaybeFromCallable#onErrorResumeNext.
Cannot resolve which method to invoke for [class io.vantiq.reactivex.Rx2Spec$__spock_feature_0_0_closure2] due to overlapping prototypes between:
	[interface io.reactivex.MaybeSource]
	[interface io.reactivex.functions.Function]
	... 1 more

This means that in these cases you have to explicitly cast the closure to whatever the functional interface class is and then it works (since these classes do only have one method in them).

This is essentially a variant of the issue that this library was intended to solve via meta-programming. RxJava2 has a few more of pseudo-functional interfaces to handle and a few more classes to instrument, but other than that it would work the same.

In fact, the constant need to add the cast has started to annoy me enough that I'm just starting on creating the RxJava 2 variant. Once I'm done I'll post a gist of that here (in case anyone else can use them).

sfitts avatar Nov 30 '17 22:11 sfitts