android / android/nowinandroid
[Bug]: Viewmodel `onCleared` method is not called unless the app is close
- Dominant language
- Kotlin
- Stars
- 21.8k
- Forks
- 4.6k
- Avg merge
- 19h 20m
- Merged PRs (30d)
- 2
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is there a StackOverflow question about this issue?
- [x] I have searched StackOverflow
### What happened?
With the introduction of nav3 `NavigationState`, onCleared method on viewModel is never executed unless the app is closed.
### Relevant logcat output
```shell
```
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Contributor guide
Research direction
Start by reproducing the lifecycle behavior in the app with nav3 NavigationState and observe when the ViewModel onCleared method should run. Trace the navigation and ViewModel ownership involved; done means the method is called when the relevant destination leaves the navigation state, not only when the app closes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100