hfhbd
04/14/2022, 1:23 PMhfhbd
04/14/2022, 1:23 PMinit(get: , set: )
. The latter requires no additional variable, but it causes Binding<String> action tried to update multiple times per frame.
hfhbd
04/14/2022, 1:25 PMnschulzke
04/14/2022, 2:19 PMalex009
04/14/2022, 3:07 PMdeclarative-ui
branch contains example of integration kotlin viewmodel directly in swiftui without any additional swift viewmodels.
https://github.com/icerockdev/moko-mvvm/blob/6a1d9da18b6650c9f364a0f72a8614fa906a596c/sample-apps/iosApp/iosApp/BookListViewBinding.swift#L19
here utils for this implementation - https://github.com/icerockdev/moko-mvvm/blob/6a1d9da18b6650c9f364a0f72a8614fa906a596c/sample-apps/iosApp/iosApp/mokoMvvmExt.swifthfhbd
04/14/2022, 3:13 PMBinding<String> action tried to update multiple times per frame.
and it does not always update the state 🤔alex009
04/14/2022, 3:15 PMhfhbd
04/14/2022, 3:18 PMhfhbd
04/16/2022, 12:09 PMobjectWillChange.send
right in the setter of the binding?
func binding<T>(_ keyPath: KeyPath<Counter, MutableStateFlow>, t: T.Type) -> Binding<T> where T: Equatable {
binding(flow: self[keyPath: keyPath], t: t)
}
func binding<T>(flow: MutableStateFlow, t: T.Type) -> Binding<T> where T: Equatable {
.init(get: {
flow.value as! T
}, set: { new in
if (new != flow.value as! T) {
self.objectWillChange.send()
flow.setValue(new)
}
})
}
alex009
04/16/2022, 3:01 PMhfhbd
04/17/2022, 9:19 PM