Hi, I'm looking for an appropriate DI framework. M...
# android
l
Hi, I'm looking for an appropriate DI framework. My app is small, maybe 20 injects and I will have a pure kotlin module, so depending on android framework would be too much. Currently I'm fired up for toothpick because its pure kotlin, but had also a look into Hilt. Does Hilt have only kotlin support or is this only available with android? Is it fine to go with Toothpick or would you recommend s.th. else?
j
I'd say take a look at Koin if you haven't already since your app is small. It's very easy to integrate. https://insert-koin.io/ It's technically a service locater but may work for your app.
2
🤔 1
d
Hilt is just Dagger with Android built-ins, so if you go that route maybe square's anvil will better suit your needs. For a small app dagger is probably more complicated than it's worth, so +1 to what jeff said 🙂
v
Why you don't like kodein? Its simple, full in kotlin and simpke use declaratie pattern/. Hilt use kapt and othher have parts)
l
Kodein is the worst if the most DI blog posts can be believed. Then I would go with either Koin or toothpick. Just of curiosity: Do you just not know it or what is wrong with toothpick?
👀 1
v
Kodein is lite, compile time, very fast and simpple to debug. If you need simpke injection without definition of modules and etc.
My app is small, maybe 20 injects and I will have a pure kotlin module
hack - try use globalConfiguration. Its kodein mode for one global config.
example bind in global conifig in app onStart
inject example
Copy code
private val blockChangeStateB by instance<AtomicBoolean>("blockChangeStateB")
and its all what need....
l
I will at least have to scope my dependencies so no gloabalConfiguration but thanks for your investigation.
d
Katana is like kodein but even lighter, its fully functional, but currently in maintenance mode...