Suppose I have an android library common module wi...
# koin
m
Suppose I have an android library common module with a single koin module specified. Suppose also I would like to run some code (also specified in common module) when that koin module is loaded. Where is the best place to put such code (note: this should not be explicitly called from outside common)?
a
you can use
createdAtStart
on a definition to create a component instance when loading it
else, there is no start hook
m
Thanks Arnaud, that’s good to know. At the moment, in my common Android library module, I declare
fun loadCommonModules()
in which I call
loadKoinModules()
and also run some code to initialise other aspects of the android library module (eg. configuring logging which is independent of Koin). loadCommonModules() is called from within the
startKoin {}
block in Application subclass.
a
yes, this is a good approach
👍 1