Does compose-desktop have a dependency injection t...
# compose-desktop
a
Does compose-desktop have a dependency injection tool? Like Hilt in Android
a
Compose Desktop is a UI framework. But Kotlin Multiplatform has some good DI frameworks which interact with Compose Desktop. KodeinDI and Koin are well known.
a
great tools, thx~
a
yeah I've been using Koin with it, which has specific extensions for use with compose.
k
Hilt is based on Dagger 2, and Dagger 2 is a Java project, not Android, so you can use it in a desktop app as well
f
https://github.com/evant/kotlin-inject not sure if it supports multiplatform
k
kotlin-inject supports multiplatform, and it’s a nice tool, I can recommend it
d
Will you truly benefit from having a dependency injection framework in your project? I feel this question doesn't get asked enough. Using one typically come at a cost over manual DI.
a
Yes, probably not necessary, I just try to use compose to other platform.
a
@darkmoon_uk always a good question. I am not a big fan of DI generally, but icw Compose and view models I must say it made application development a whole lot faster
c
Dependency injection is a great convention to use if you want to write testable business logic, regardless of which UI framework you’re using.
e
Using one typically come at a cost over manual DI
I think its better to specify what costs @darkmoon_uk. To answer, you reap the benefits of a DI framework (eg Dagger) over time so its worth it to compare that to the initial setup cost (which is usually the only cost associated with these). Vs manual DI which has no upfront setup cost but has incremental cost the more your application grows.