Lilly
02/19/2023, 3:15 AMmulti-module project
and utilizing a DI library
. In particular I think about KOIN as DI library. You have to instruct your application somehow to load all koin modules (not gradle modules) to build the dependency graph. One option to achieve this, is to create a separat gradle module, lets call it di which is aware of all other gradle modules, so the app module can simply depend on it and can load the koin modules from there. Further, I came up with idea to put all koin modules in di gradle module rather than let every gradle module provide its koin module. The advantage is that all other gradle modules are independent of a DI library but the disadvantage is that almost every class of the other gradle modules has to be public so that di module is aware of the references. My question is: which approach would you choose and why? I tend to let the other gradle modules provide their koin modules, what do you think guys?curioustechizen
02/20/2023, 6:54 AMstartKoin
.
I haven't found a way to make all my feature modules to be unaware of koin. Specifically, sometimes I need my presentation modules to use specific features of koin (for example my Composables need to call getViewModel()
etc).
Instead I try to make individual classes to know less about the DI library being used. I try to limit myself to using constructor injection as far as possible - then (as long as I don't use annotations), these classes have no knowledge of what DI library is being used. Only the koin DI related code does.Lilly
02/20/2023, 5:40 PM