Dependency injection in kotlin? The android docs s...
# getting-started
s
Dependency injection in kotlin? The android docs say to use Hilt, which uses Dagger. The next top result is Koin… I’m doing command line + server apps on jvm at the moment. Any recommendations?
m
k
I think most of them are Service Locators. If you’re looking for DI library these two might be interesting for you: • https://github.com/evant/kotlin-injecthttps://github.com/corbella83/PopKorn
1
m
There’s nothing really wrong with Guice if you’re comfortable with that (assuming you mean runtime dependency injection)
m
I'm really liking koin https://insert-koin.io/
👍 1
s
The one time we build a Kotlin server app without Spring, we used Ktor and Koin (which was very straightforward/lightweight and worked like a charm).
👍 1
m
@Sam Howes if you’re doing mostly CLI and server just discard the libs specific for Android, like Hilt
s
@Matteo Mirk would you personally use Dagger over Koin?
m
Both operate at compile-time, which is desirable to me. If the choice is just between the two, I’d go with Koin because I prefer using explicit DSL over annotations.
👍 1
s
Thanks!