How come there is no way to register a callback ou...
# koin
m
How come there is no way to register a callback out of the box for a lazy loaded module so that you can do something "onLoaded()" - is something like this considered out of scope for a DI framework? Just curious
a
feedback never emerged until now, but it's interesting. We made this for async module loading in coroutines, on loading jobs itself. Can you precise a bit more what you are looking for?
m
• I use koin for DI in a KTOR project. • I have hooked up Feature Flags from Unleash. • I have an abstraction that basically is a "Feature" - when the unleash flag is toggled on, I load a lazy module with koin and when it is toggled off, I unload the module • At the moment the "Feature" abstraction lets me register onLoad and onUnloaded callbacks • In an onLoad callback I might find my Backend API singleton and register a new controller to it or something along these lines • I have a Feature Manager and I had to give it a reference to Koin to let me do the onLoad and onUnloaded calling - just felt wrong. I think I would have preferred to have the module be able to self declare I do get though that my use of Feature Flags might not be exactly right and was just curious if lifecycle management like that was considered out of scope