New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onClose not called on single, works when define in scope #834
Comments
From looking at the source code I think the This seems like a major problem, but apparently not many people are using |
So will it be fixed? Because if you have this functionality, it should work or move the onClose to only support for Scope defenition |
To better understand this: Is this actually a bug or is If this is a bug that needs to be fixed I'd be willing to have a look at it when I get the time. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
For me this seems like a bug, it's weird that you can define an onClose method which isn't actually called when closing. And I don't see a reason why this shouldn't work for the root scope of a module. But I might be wrong, my understanding of Koin is limited. |
not a bug, as for now single definitions need to be dropped with module unloading, not closing it. It's more an issue to be able to write |
This issue is outdated. The following test is running successfully: @Test
fun test_onClose_from_unload(){
var closed = false
val module = module {
single { Simple.ComponentA() } onClose {
closed = !closed
println("closing ComponentA - closed = $closed")
}
}
val koin = koinApplication {
printLogger(Level.DEBUG)
modules(
module
)
}.koin
assertTrue(!closed)
koin.unloadModules(listOf(module))
assertTrue(closed)
koin.loadModules(listOf(module))
koin.unloadModules(listOf(module))
assertTrue(!closed)
} |
// do some work
unloadKoinModules(module)
}
The text was updated successfully, but these errors were encountered: