Hi all I tried to add ```implementation("com.badoo...
# reaktive
d
Hi all I tried to add
Copy code
implementation("com.badoo.reaktive:rxjava3-interop:1.3.0")
into
compose-multiplatform-ios-android-template
and I am getting errors.. Could somebody help to figure out with it ?
a
RxJava interop is only available for JVM and Android, because RxJava is a Java library. It can't be used in a shared code targeting non-Java platforms.
d
Oh, you are right I missed it Thank you!
@Arkadii Ivanov what is about coroutines interop ? It should be for iOS ?
I mean in theory. I see that now it is not supported
a
Yes, it should work for iOS. Please check the readme, as there are some tricky things.
It is supported
Assuming you are using the new memory model, if you are using Reaktive v1.x then you should use
-nmtc
version of
coroutines-interop
module (e.g.
com.badoo.reaktive:coroutines-interop:1.3.0-nmtc
. With Reaktive v2.x it should just work.
d
I use Reaktive v2 I see that problem with
androidx.compose.runtime/collectAsState
I am trying to use Reaktive with iOS Compose like that
Copy code
@Composable
fun StringListView(
    viewModel: ListViewModel<String>
) {
    val items = viewModel.items.asFlow().collectAsState(emptyList())
....
a
Well. You could just write your own collectAsState for
Observable
and/or
BehaviorObservable
. So that you don't need to use the coroutines interop at all. From the top of my head.
Copy code
fun <T> Observable<T>.collectAsState(initialValue: T): State<T> {
  val state = remember(this) { mutableStateOf(initialValue) }

  DisposableEffect(this) {
    val disposable = subscribe { state.value = it }
    onDispose(disposable::dispose)
  }

  return state
}

fun <T> BehaviorObservable<T>.collectAsState(): State<T> =
  collectAsState(value)
But your approach should also work. What's the error?
d
Untitled
a
Oh, I believe there are multiple similar known issues with Compose for iOS! The first thing is to try a workaround from https://github.com/JetBrains/compose-multiplatform/issues/2046. If doesn't help, you could search and/or ask #compose-ios.
d
looks like problem was that “shared compose ios framework” can be only static if you use cocoapods for integration
your workaround helped, thank you! static framework was a second problem 😃