Hi all, I wonder if anyone has hands-on experienc...
# multiplatform
k
Hi all, I wonder if anyone has hands-on experience with
Flow
in MPP/KN modules? Got any tips & tricks? I'm trying to expose shared repository layer for iOS/Android, and considering which
Observable
implementation to expose. Would really like to avoid
Reaktive
, having already coroutines and RxJava in the project... Thanks in advance!
a
Flow can not be directly exposed to Swift as suspend functions are not available from there. You will need to wrap Flow into something based on regular callbacks with cancellation. Reaktive can be exposed. Also both Flow and Reaktive are based on extension functions. They are a bit hard to call from Swift. We are considering Swift extensions for Reaktive.
k
Take a look at this: https://github.com/JetBrains/kotlinconf-app/blob/master/common/src/mobileMain/kotlin/org/jetbrains/kotlinconf/FlowUtils.kt They created
CFlow
which exposes a watch function that you can use on Swift. On your
Flow
, you can use
wrap()
to transform it to a
CFlow
then to consume it you use
Flow.watch { ... }
k
Thank you for the responses! That's really helpful!