Hey all :wave: Is there a better way to make `onCl...
# koin
s
Hey all 👋 Is there a better way to make
onClose
work on Desktop besides manually calling
koin.close()
from a ShutdownHook?
a
Is it really necessary? Since the app is closing anyway?
s
Yes, to close important resources.
m
What about
Copy code
fun main() {
    val koin = startKoin {
        modules(appModule, desktopModule)
    }
    application(exitProcessOnExit = false) {
        Window(
            onCloseRequest = ::exitApplication,
            title = "Demo App",
        ) {
            App()
        }
    }
    koin.close()
}
I haven’t tested it but it should do the job.
👍 1
s
That could probably also work. There are other options like
awaitApplication
which I can use in combination with
SuspendApp
if I'd also want to react to
SIGTERM
. I was surprised there was no support for this out-of-the-box ☺️