Closed slickorange closed 8 months ago
I found the issue in the pull request #162 from @aftabahmadTW that removed the LifecycleOwner
responsible to manager the ViewModel
lifecycle. Without that the ViewModel lifecycle will be scoped to current Activity and keeping alive until the Activity is destroyed.
CC @adrielcafe @DevSrSouza
Probably because you use singleton for your screen.
- Because you don't provide a tag when you get the viewModel.
As I mentioned, this used to work and only started happening once I updated to the latest version. (Without making any changes to my viewmodels or navigation.
Also not sure what you mean by providing a tag - I am just using the method showed in the documentation..
@slickorange try rollback to RC06
. Pull request #162 is on the RC07
. We will try fix that 👍
I am having trouble with RC06 and the latest version of Jetpack compose.
I'm on RC06 and it's not working
Any updates on this?
I am still seeing this issue with the latest version (1.0.0-rc08)
The main issue here is that we change the behavior of AndroidScreenLifecycle
, removing it from the AndroidScreen
and injecting it by default for all screens.
Your implementation of hilt viewModel extension was based on the fact that the Screen should be a AndroidScreenLifecycle
. I figure this out late yeasterday.
The PR #212 from @programadorthi fix that issue by not casting Screen.lifeycleOwner
to AndroidScreenLifecycle
and instead using LocalLifecycleOwner
, we should try reopen it and merge it to next release.
Fixed on 1.0.0-rc09
I am using
AndroidScreen
withHiltViewModel
When the screen is disposed, the viewmodel is not cleared.
Another issue, which I am not sure is related, is that screens of the same type share viewmodels. Eg. I have a
LessonScreen
which displays a lesson. When I go from "lesson A" to "lesson B" by pushing a newLessonScreen
the screen for LessonB does not get it's own instance of the viewmodel (this was the behaviour when I used RC 5, but not what I see with 7)I am pretty stuck and would appreciate any help