-
Notifications
You must be signed in to change notification settings - Fork 2k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HiltViewModel with @AssistedInject and key parameter on creation #4481
Comments
Can you share some code on how you are retrieving the ViewModels and the custom factory? Is the key being passed to the |
Sure, thanks for the quick response. ViewModel creation:
Assisted Factory:
|
If you are passing a On the androidx side we have a test that validate that the key being used in This same key is also piped in the version that uses assisted injection. |
I have two different ViewModels being initialized in two different composables that are in the same route but on different hierarchy levels, using a custom factory, that passes a key parameter which is a user id.
It seems that Hilt replaces the first of those ViewModels based on the id passed via key, even if they are different ViewModels.
Expected behaviour:
Before checking the key parameter, Hilt looks at the ViewModel type to decide to replace.
Versions:
Hilt Version 2.49
Hilt Navigation Compose 1.2.0
The text was updated successfully, but these errors were encountered: