I’m wondering which is the best way for handle a m...
# koin
d
I’m wondering which is the best way for handle a multi-module app with koin. Actually I got an Android project and a structure like this (
->
= depends by ):
Copy code
app -> feature modules 
&
app -> "DImodules" module
&
DImodules -> all other modules ( feature and business )
In this way app takes a reference to all the koin modules from DImodules, without directly depend by them, but I don’t think this is an awesome solution. Also I would like to invert the dependencies and let feature modules depends by app, but in this way I would have a dependency circle
features -> app -> DImodules -> features
. Removing DImodules I wouldn’t know how to initialize other modules 🙄
👍 1
a
you can have a feature module with its own DI declaration
you can use
loadKoinModules
at anytime to load a module
d
Thanks, that sounds good. I'm also wondering if there is any way to define a sort of "contract" for load X modules when a Y "component" call Koin. I could use some extension functions for do that, but maybe there is something already in the framework
a
until now, nobody claimed clearly for a import or link between modules feature
as everything is dynamic
but you can also use the
checkModules
test function to be sure that your modules are really working or not
d
Ok I will take a look thank you so much
👍 1
I'm able to autoinject the feature module with the above the first time the screen opens, it's by lazy so on activity recreation it won't be called
👍 1