Casting LifecycleTransformer to Transformer
Closed this issue · 3 comments
I recently upgraded RxLifecycle in my project from 1.0 to 4.0.2.. One of the things that broke was this.. I was passing a Transformer
into compose
but with new changes, bindUntilEvent
returns a LifeCycleTransformer
..
I think I can cast it to Transformer
but don't know how.. Or am I missing something else here?
My code snippet:
.compose(bindUntilEvent(ActivityEvent.PAUSE))
Error message:
Required type: Transformer <? super Void, ? extends R>
Provided: LifecycleTransformer <Object,
reason: no instance(s) of type variable(s) T exist so that LifecycleTransformer conforms to Transformer<? super Void, ? extends R>
You have to define T
in this case. See the sample for an example: https://github.com/trello/RxLifecycle/blob/master/rxlifecycle-sample/src/main/java/com/trello/rxlifecycle4/sample/MainActivity.java#L49
@dlew after investigating this issue a bit more, I have found that the latest version of RxLifecycle
depends on RxJava3
but I'm using RxJava1
which is likely why my compose method is expecting a Transformer
.. I just wanted to double check this with you.. that in order to use the latest version of RxLifecycle
, my project should also use RxJava3
- is that correct?
Yes, the different major versions of RxLifecycle are tied to different versions of RxJava. In particular, RxLifecycle 1 == RxJava 1, RxLifecycle 2 == RxJava 2, and RxLifecyle 4 == RxJava 3. (RxLifecycle 3 had to do with AndroidX, another major dependency.)