when i create a Single definition in my module is ...
# koin
y
when i create a Single definition in my module is there any way for me to dispose that class and create an other one, while preforming a specific task? i don't want to use factory because a brand new class gets created every time I get it using koin, I want to have more control of creating the classes is that possible??
w
you could unload and load the module
thank you color 1
p
You can use the proxy pattern. Declare a proxy as a Singleton, inside the proxy you will have various instances of the same proxy class and you switch the Active one at runtime, accordingly to your business needs.
thank you color 1
z
You should use Koin scopes and declare this definition as
scoped
. Then you'll have control of when this scope should be created/closed.. We tried to unload/load modules once but those changes are not immediately applied (it's mentioned in the documentation), so we ended up having some random "definition not found" exceptions.
y
for now, the loading and unloading of the module have worked fine for me, but thanks for the advice
👍 3
@Zacarias lol it worked fine then the issue that you mentioned happened
😅 1