With KMP compatible version of `ViewModel` now ava...
# koin
j
With KMP compatible version of
ViewModel
now available (https://developer.android.com/jetpack/androidx/releases/lifecycle#2.8.0-alpha03) does it make sense now to have Koin's
viewModel
available in KMP code?
👀 4
a
Interesting. Koin provide the factory and allow to declare it by DI. I would say that's even cool that now it's becoming more compatible for KMP
viewModel
provides the DSL & binds to factory, Perhaps less need of KMM-ViewModel I would say
or did I missed something? 🤔 😛
j
Main benefit of KMM-ViewModel now is converting StareFlow to swift observable property
Well, main benefit now I guess given this development. Also wondering if likes of SKIE could provide this functionality.
Also not clear about how lifecycle of view model would be managed on iOS when using this.
if we have multiplatform version of
viewModel
DSL then I guess follow on question is how we access instance of view model in swift/swiftui
When using KMM-ViewModel I typically subclassed
KoinComponent
so I could just instantiate it directly in SwiftUI
a
Yeah, the basic iead for Koin is to provide ViewModel building out of the box and simplify assembly
j
I've merged initial set of changes to https://github.com/joreilly/FantasyPremierLeague/ to use shared androidx based view models
I'm using
viewModel
DSL for most part on Android and creating explicitly in SwiftUI in iOS client.....where things get interesting is where I'm injecting view model in to shared composable....for now ust using
single
in shared module for that
a
interesting, could be a "reusable" reference where as long as there is ref on it, we keep it
s
I'd be interested in having koin support for view models with the multiplatform compose navigation. with the
org.jetbrains.androidx.navigation:navigation-compose
library, I can basically use the nav graph i'm using on android with my desktop app, except I have to do the vm injection different. haven't explored it much ios yet but I'm guessing it's about the same.