Is there any way to extend a kotlin class in commo...
# multiplatform
m
Is there any way to extend a kotlin class in common from
Combine > ObservedObject
so that we can use as
@ObservedObject
in SwiftUI views ? Or do we have to create a wrapper for each viewModel ?
j
Just my 2c but I think in that case there's isn't a lot of value in having view models in shared code....what you might have though are what I think of as "view model helper" classes that are then used by "native" view model (based on ObservableObject on iOS and AAC ViewModel on Android)
☝️ 1
m
Thank you for you reply, yes i read this one, it is really interesting one and has many benefits, but I do not like the idea of creating view model in each platform for each screen. Because we can achieve viewModel for Android and JS in common probably it will be better to duplicate only on IOS side. On the other hand I am really wondering if I really need to use
Combine, ObservedObject
with
@ObservedObject
and
@Published
vars on IOS side or better to use straightforward approach like here: https://github.com/kuuuurt/jokes-app-multiplatform/blob/master/ios/JokesApp/ViewController.swift
👍🏻 1
s
m
this one was interesting too will try this also thanks a lot!