is there any way to restart Koin? I'm facint the s...
# koin
p
is there any way to restart Koin? I'm facint the same issue than this guy, some values of my Koin singletons changes so I need to reload them: https://stackoverflow.com/questions/63290183/android-koin-how-to-tell-koin-that-a-single-dependency-should-be-reinitialized unloading and reloading the modules doesn't work, as it is a singleton, and seems that Koin still keeps the cached singleton in memory, and doesn't unload/reload it
Copy code
unloadKoinModules(networkModule)
loadKoinModules(networkModule)
do exist any solution for this? any solution that doesn't implies adding complexity like factories that embeds a singleton and checks if a variable has changed and then returns another singleton, I don't like that approach. I'm considering restarting the entire application, but seems that android doesn't offers a 100% supported way to achieve this. Something like
unloadKoinModulesIncludingSingletons(networkModule)
will be perfect. The solution proposed by that guy is not posted in the link anymore, and the alternative of doing
val api: InstanceApi = getKoin().get()
is not applicable in my case. I tryed doing stopKoin and startKoin again, but the modules are not being reloaded, don't know why.
s
Consider using Koin Scopes to define a lifetime for your singletons. With this approach, you can have singleton-like behavior (one instance shared across a scope), but allows you to destroy and recreate entire scopes