I'm considering between Hilt and Koin. Hilt has on...
# koin
t
I'm considering between Hilt and Koin. Hilt has one ideal function for me. It is possible to use it between own libraries. We have a lot of libraries in our company and it is very hard to initialize them manually. Because libraries has dependency on each other and needs a some configuration data from app. I want to use DI for that, every library will get all dependencies directly in constructor. I don't need to care about initialization order and it will be even lazy. Only libraries that I will really need will ne initialized. For example if app starts just to do some schedule job I don't need to init everything. And in Hilt is enought that one library provide something and another injecting it. You don't need to do anything you just add both libraries to dependencies and connection between this library is automatically created during compilation time. Is this possible also in Koin? To automatiky search provided and injected stuff inside of libraries in the fast way?
a
Yes Koin can be use as "isolated" to be embedded in ay SDK
performances of requesting instance is around 0.005/0.01ms. After that you add complexity of object that you create
t
I need exact opposite of isolated 😉 I need ability that one library will provide some implementation and another one will be able to inject it, just by adding dependencies to the project.
a
ha 😅 you can share context between parts, and allow those parts to load stuff on it
t
There is even global context that should be shared. But I'm asking if Koin can automatically collect all modules from all dependencies and add it to that global context. By using Koin Annotation of course. Hilt automatically put special package to the library and when you use this library in your app hilt just check that one package in all dependencies during build and use all providers and fulfill all injection in them.
a
with Koin annotations it's convenient to use @ComponentScan
this will scan everything over Gradle modules
t
I will experiment with that. So far I'm using @ComponentScan in individual modules/libraries to create list of possible implementation as source for new Module. But on the app level I would then need something like
ModulesScan
which will find all modules in all libraries.
a
could be a fun feature yes. You can open a feature request on the project github 👍
t
a
argh, can you make it koin-annotations project then: https://github.com/InsertKoinIO/koin-annotations/issues
t