Solution 1 :
After doing A LOT OF RESEARCH, I found this post on GitHub scoping is the solution for my problem.
— OR —
using
unloadKoinModules(networkModule)
loadKoinModules(networkModule)
and then get the instance again:
val api: InstanceApi = getKoin().get()
Problem :
I stumbled across a problem where I have to reinitialize my Retrofit API class because the URL changes, so I want to tell Koin to reinitialize the single dependency. I don’t want to use factory because it is still a singleton most of the time.
Stopping and starting koin would be an idea but that is a very heavy and time intense prozess so I don’t want to do that.
any ideas?
Comments
Comment posted by Rinat Diushenov
why don’t you create 2 instances with 2 different base urls?
Comment posted by kaulex
The problem is that this case can happen more often then 2 times so I would need to create a new retrofit instance every time I use it. SO I thought about solving it in koin, to recreate only one single dependency
Comment posted by ivan8m8
But the isuue author wrote about a leak. Do you consider that?
Comment posted by kaulex
I just mentioned the issue because it is providing the solution. It is not the same issue I had. Never had problems with the solution here.