Skip to content

HiltViewModel with @AssistedInject and key parameter on creation #4481

Open
@peterMonteer

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions