https://kotlinlang.org logo
#koin
Title
# koin
m

Merseyside

10/10/2023, 10:48 AM
Could I know somehow is module will be override by another module or already loaded? I'm trying to load modules when scope creates. F.e we enter some screen, load module with scope and when we left the screen, scope closes, module unloads. I have a trouble when I open few similar screens, and load modules on each of them. Then when we left the screen, module unloads and previous ones can not provide instances anymore. In conclusion, how can I know module already loaded in order not to load it again or just to be sure that it's hasn't been loaded before?
a

arnaud.giuliani

10/10/2023, 11:38 AM
on a module variable there is a
isLoaded
value
you can activate Koin logs if you need more insights
m

Merseyside

10/10/2023, 11:45 AM
Oh, thanks a lot, my bad:)
a

arnaud.giuliani

10/10/2023, 11:51 AM
no pb 👌
m

Merseyside

10/10/2023, 12:35 PM
As I can see in implemenation of Module.kt isLoaded is true if mappings count is not zero. As for me it will be always true if our module is not empty. F.e we add single. In implementation of Single "indexPrimaryType" method calls, then "saveMappings" and there mappings are inflated => mappings not empty => isLoaded == true
a

arnaud.giuliani

10/10/2023, 3:04 PM
yes, not helping then 🤔
m

Merseyside

10/11/2023, 6:38 AM
@arnaud.giuliani Maybe add a flag when module is loaded with loadModules or on koin startup?
a

arnaud.giuliani

10/11/2023, 4:27 PM
perhaps yes 🤔
2 Views