Is it possible to observe kotlin class properties ...
# kotlin-native
m
Is it possible to observe kotlin class properties in swift? Like with
ObservableObject
and
Published
in swiftUI.
h
j
Another option is to use https://github.com/rickclephas/KMP-NativeCoroutines and can map Flow/StateFlow in shared code pretty seamlessly to Swift AsyncSequence
👍 1
h
But with NativeCoroutines you still need a Swift ViewModel to update the values, or SwiftUI.State variables
j
yeah, that's true....for me that's worked out ok but I guess it depends on architecture/setup you're using
In my case I'm consuming
StateFlow
(as
AsyncSequence)
from repository (in the Swift ViewModel) and, in some cases anyway, mapping/transforming/combining that before assigning to
@Published
the property
m
Thanks for the tip guys!