Does anyone know how exactly
koin-androidx-compose
hooks compose UI with the ViewModelStore to notify it that the composable is disposed so viewModel should be removed from the store?
I am having the weird situation, when I just remove from the composition a screen, I can see that the
DisposableEffect
triggers its onDispose, but the view model is not cleared.
And when the screen returns into the composition - the same instance of the view model is provided. Although I don't scope it to activity or anything. Just using bare
org.koin.androidx.compose.getViewModel()
.
So in practice we have a composable screen with its viewmodel. It triggers API and gets 401. The not authenticated state delivered and this screen just goes out of the composition via if(logged) and Login screen is the only screen in the composition.
And then we close the login, and re-create the initial screen - it gets old view model instance.
And the more weird part is that if I just close the screen via back button (having Voyager for navigation), the view model does get cleared.
Any hints?