Hey :wave: Is there any "unload-hooks" functional...
# koin
r
Hey 👋 Is there any "unload-hooks" functionality one can achieve with Koin? For example: You have some components that need to explicitly clean up and just removing a reference to it is not enough. You could let these components extend an interface that makes it clear that these components need to do clean up (
class A : Disposable
).
Disposable
offers a
dispose
function that every such component needs to implement. Is there a way to let Koin trigger
dispose
of all loaded dependencies once
unloadModule(...)
is called?
For other people interested in this: It seems like there is no purely automatic way of achieving this, but in combination with the
onClose
callback on definitions it's easy to solve it looks like: https://github.com/InsertKoinIO/koin/issues/600#issuecomment-541404782
a
Possible 🤔
do you have a sample to help see that?
r
The issue is tracked here with an example: https://github.com/InsertKoinIO/koin/issues/834