rickclephas / KMP-ObservableViewModel

Library to use AndroidX/Kotlin ViewModels with SwiftUI
MIT License
569 stars 29 forks source link

Nullable Swift bindings #37

Closed humblehacker closed 1 year ago

humblehacker commented 1 year ago

Given the following property in a Kotlin view model class:

@NativeCoroutineState
val price: MutableStateFlow<Double>

it is exposed to Swift as:

Binding<Double>

But if I make it nullable:

@NativeCoroutineState
val price: MutableStateFlow<Double?>

I get this in Swift:

Binding<KotlinDouble?>

which requires ugly conversion on the Swift side.

Is there something I can do to improve this?

humblehacker commented 1 year ago

Actually, I think this has nothing to do with Bindings per se -- the bare property exposes the discrepancy. I'm moving this over to KMP-NativeCoroutines.