https://kotlinlang.org logo
#compose
Title
# compose
u

uptoyou

12/23/2021, 12:09 PM
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
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
and that is supposing you want to only do jvm
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
☝️ 1
u

uptoyou

12/23/2021, 1:01 PM
It has some issues with Kotlin 1.6.+ support (this is my taboo, it's not that hard to support newer versions) and some other very very old https://github.com/InsertKoinIO/koin/issues?q=is%3Aissue+is%3Aopen+sort%3Acomments-desc . So i decided that the pace of it's maintainance willn't keep up with Compose + KMM
j

Joost Klitsie

12/27/2021, 10:11 AM
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.