Hello. I am really, really unsure on how to access...
# multiplatform
a
Hello. I am really, really unsure on how to access the badoo.reaktive
Single
from my native Android app . I have the following:
Copy code
fun getAssignedBooks(): SingleWrapper<List<String>> {
    return singleFromCoroutine {
        callAssignedBooks()
    }
        .subscribeOn(ioScheduler)
        .observeOn(mainScheduler)
        .wrap()
}
But when I try to do this:
Copy code
val assignedBooks = SharedBookRepository().getAssignedBooks()
assignedBooks.subscribe()
I get this:
Cannot access 'com.badoo.reaktive.base.Source' which is a supertype of 'com.badoo.reaktive.single.SingleWrapper'. Check your module classpath for missing or conflicting dependencies
Cannot access 'com.badoo.reaktive.single.Single' which is a supertype of 'com.badoo.reaktive.single.SingleWrapper'. Check your module classpath for missing or conflicting dependencies
Any ideas why ? 😞 I'm using RxJava2 in my native Android app, I'd also like to chain the
getAssignedBooks()
with other observables and singles using
.flatMap()
and such, but not sure how I can do that. And it's been stressing me out for the past hour+
a
Most likely you need to either add Reaktive as an
implementation
dependency to your Android app module, or make Reaktive
api
dependency in your shared module.
For interop with RxJava2, Reaktive provides
rxjava2-interop
module which you can use in your Android app module -
implementation "com.badoo.reaktive:rxjava2-interop:<version>
a
Regarding rxjava2-interop ... how would I go about doing that? I failed to find a proper doc in that regard ... 😞 And if I convert to an rxjava Single, i won't be able to use the same method in Swift then, no? I need it to be a SingleWrapper for swift ... Or am i missing something ?
a
RxJava is only required if you need to perform conversions RxJava<-> Reaktive. Some use cases are: 1. You have a Reaktive Observable exposed from your shared module, and you need to pass it to a method that accepts RxJava Observable. This could be an existing RxJava-based code on the Android side. 2. Your shared module accepts Reaktive Observable, but you have an RxJava Observable in the Android app. You can check what extension functions are available - https://github.com/badoo/Reaktive/tree/master/rxjava2-interop/src/main/kotlin/com/badoo/reaktive/rxjavainterop E.g.
rxJavaObservable.asReaktiveObservable()
,
reaktiveObservable.asRxJava2Observable()
If you don't have any existing RxJava code, then most likely you can use Reaktive if it would be RxJava. E.g. apply operators, subscribe, etc.
a
ok, so simply changing from
implementation
to
api
in my shared module's build.gradle ... made it work. It seems i'm missing some basic understanding of gradle but why did api work instead of implementation? 😑
a
It tells Gradle to expose the library from your module, so it can be used by consuming modules. Useful when consuming modules would have to add the library anyway.
a
That is a wonderful piece of knowledge I should have known already. Thank you very, very much for that ! I never used it before. :)