Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork771
Fix sharedKoinViewModel fails with type-safe navigation routes#2293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
arnaudgiuliani commentedOct 20, 2025
I don't see why it bring stronger verification here, as the compiler should already help here. |
nazaburo commentedOct 20, 2025
@arnaudgiuliani |
arnaudgiuliani commentedOct 21, 2025
Do you have a test case to reproduce, something we can add into examples project, the android compose app? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull Request Overview
This PR fixes a bug wheresharedKoinViewModel fails when using type-safe navigation routes. The fix adds conditional handling to support both string-based and type-safe (object-based) navigation routes.
- Adds type checking to handle both String and non-String route types
- Ensures
getBackStackEntryis called appropriately for both route formats
Tip: Customize your code reviews with copilot-instructions.md.Create the file orlearn how to get started.
| if (navGraphRouteisString) { | ||
| navController.getBackStackEntry(navGraphRoute) | ||
| }else { | ||
| navController.getBackStackEntry(navGraphRoute) | ||
| } |
CopilotAIOct 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Both branches of the if-else statement execute identical code. The conditional check serves no purpose and should be removed, leaving onlynavController.getBackStackEntry(navGraphRoute).
| if (navGraphRouteisString) { | |
| navController.getBackStackEntry(navGraphRoute) | |
| }else { | |
| navController.getBackStackEntry(navGraphRoute) | |
| } | |
| navController.getBackStackEntry(navGraphRoute) |
nazaburo commentedOct 22, 2025
@arnaudgiuliani Added:
You can test it by running the app and tapping "(>)Type Safe Navigation Example" or "(>)String Navigation Example". Both examples demonstrate that screens share the same ViewModel |
Uh oh!
There was an error while loading.Please reload this page.
Fix sharedKoinViewModel fails withtype-safe navigation routes#2292