ViewModel onCleared is not being called when using custom scopes with Koin in Jetpack Compose
I use Koin
with Jetpack Compose
. I have to create a custom scope for one of my ViewModels
as it should stay alive as long as the user is logged in.
I tried to do that in my composable, wrapping it in rememberSaveable
and creating a custom Saver
for that scope, but on every configuration change a new instance of my Scope
was created. So I used one of my ViewModels
as a holder for that scope. That ViewModel
is single, so there is nothing to worry about.