I'm no iOS expert but if the KaMPKit project share...
# touchlab-tools
a
I'm no iOS expert but if the KaMPKit project shared code up to the viewModel level, why is the shared viewModel wrapped inside an
ObservableObject
on the iOS side??
k
This is so that the shared code works with the
Combine
framework on iOS and can be used to hold the state of the
SwiftUI
views.
r
To say a little bit more: the viewmodel is shared, but Kotlin/Native doesn't know anything about Swift or SwiftUI, so we need to add some extra infrastructure to bind that shared viewmodel to the UI. It might help if you can say more about what you would have expected to do otherwise.
a
@russhwolf I expect to be able to consume the state from SwitfUI and invoke the viewModel functions too. I just wanna understand why that extra layer.
r
The extra layer is so that the viewmodel can continue to use coroutines and flows and all the usual Kotlin conventions, and only the Swift code needs to make adjustments to bind that to the iOS UI