what DI framework is more preferable to maximize shared code in KMM project ? I viewed custom implementation from Anna Zharkova (
https://www.youtube.com/watch?v=Z3KhZzAhCIY▾
) but consider it as a fallback choice. Maybe someone has experience with Hilt and some custom extensions ?
j
Javier
12/23/2021, 12:44 PM
hilt (strictly hilt) will work with android part, jvm not
Javier
12/23/2021, 12:45 PM
you can share a lot with dagger + hilt in desktop + android apps but hilt magic don't exist in jvm apps so you will have to do it manually as it was done with dagger 2 before
Javier
12/23/2021, 12:45 PM
and that is supposing you want to only do jvm
Javier
12/23/2021, 12:46 PM
if you want to use compose web and/or a fully kmp app which doesn't use compose in other places like iOS, you will need to use another framework like koin or a custom one
u
uptoyou
12/23/2021, 12:51 PM
Yep, i'm talking about Android/iOS sharing (KMM) , currently i'm more inclined to not share much and do Hilt way on Android as Mitch suggest
https://youtu.be/7Lz9mvnK-x8?t=793▾
j
John O'Reilly
12/23/2021, 12:52 PM
Koin supports both Compose and KMM....pretty easy to setup and use
I'd use kodein, it is pretty easy and is multiplatform for a while now. I made a kmm project with a server (ktor) where kodein has helper methods, it is now ready for Jetpack compose as well (even though I wrote my own helper functions which anyway did the (same) trick before that) and it was easy enough with similar helper methods to jetpack compose, to use it for the kotlin js react part as well.