I have a quick question: Is there any notion of a ...
# koin
a
I have a quick question: Is there any notion of a standard life cycle in the within the Koin container? I would like Koin to call
stop()
or something on singleton the moment the
stopKoin()
gets called. According to the doc calling
stopKoin
should release all resources. But i’ve even If implement Java’s
Closable
interface the close never gets called. I have also tried the
AutoClosable
interface, and no joy?. Any idea to get this short of me manually implemented a
AutoClosableResourceManager
and explicitly call close on it?
1
p
If I would want to release that I would look more on Scopes and how to use them. Scoped allows you to Close it and should do the trick.
thank you color 1
💯 1
s
We use Scopes and a separated NavGraph to represent different logged-in user sessions, and to allow the authenticated UI to operate without the concern of managing sessions and clearing caches. i.e.
Copy code
CompositionLocalProvider(LocalKoinScope provides sessionScope) {
  AuthenticatedNavHost( .... )
}
❤️ 1
a
Looks like a nice solution. Will test something similar. I'm using Koin on the server side, because i feel spring framework is just too heavy. Sofar Koin starts up really snappy without pulling in a massive chunk of jars from Maven Central. And I do not have to play puzzles with annotations
p
So you are using Spring Boot + Koin?
a
@Pedro Alberto at the moment, H2 database and command line only. Using Koin to wire up data source for state process storage and the local file system for things not suited for RDBMS. When it grows up, I plan to move to Ktor (for an http rest interface) + Postgres + Koin.
🫡 1
p
Topic for a nice talk 🙂 how to migrate from Spring to Ktor using Koin as leverage. Sounds mega interesting.
a
That is the plan. 🙂
👌 1