https://kotlinlang.org logo
#koin
Title
# koin
j

John O'Reilly

03/21/2024, 8:24 AM
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

arnaud.giuliani

03/22/2024, 2:21 PM
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

John O'Reilly

03/22/2024, 2:23 PM
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

arnaud.giuliani

03/22/2024, 5:27 PM
Yeah, the basic iead for Koin is to provide ViewModel building out of the box and simplify assembly
j

John O'Reilly

03/23/2024, 2:52 PM
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

arnaud.giuliani

03/25/2024, 8:14 AM
interesting, could be a "reusable" reference where as long as there is ref on it, we keep it
6 Views