https://kotlinlang.org logo
m

Mike

07/13/2023, 5:54 AM
(Swift interop) Hi, I know that we can use SingleWrapper and ObservableWrapper (per https://github.com/badoo/Reaktive/blob/master/docs/SwiftInterop.md) to use KN reaktive observables in Swift code, but is there any way to create a reaktive observable from Swift code so it can be used in KN code? In particular I have some platform specific functions on iOS/Android that should return a reaktive observable, and I'm trying to use it in some KN common code.
a

Arkadii Ivanov

07/13/2023, 6:48 AM
In theory, you can call Reaktive functions. But there will be no generic support. And the code will be ugly because you can't call extensions as usual, you will have to call operators as functions and pass observables in there. I recommend that you define a function in Kotlin, that accepts arguments from Swift and returns ObservableWrapper.
m

Mike

07/13/2023, 6:49 AM
Got it, thanks for the suggestion. Currently I'm declaring a BehaviorSubject in KN code, and then RxSwift publishes results to that BehaviorSubject so that kotlin can subscribe to it