Skip to content
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

Named qualifier does not work with view models #452

Closed
koral-- opened this issue May 14, 2019 · 3 comments
Closed

Named qualifier does not work with view models #452

koral-- opened this issue May 14, 2019 · 3 comments
Labels
android status:checking currently in analysis - discussion or need more detailed specs type:issue
Milestone

Comments

@koral--
Copy link

koral-- commented May 14, 2019

Describe the bug
When providing ViewModels using viewModel with named in module and injecting using by viewModel the same instances are injected regardless of names. If we use single and by inject respectively, names are taken into account properly.

To Reproduce
Steps to reproduce the behavior:
Use code like this in module:

    viewModel(qualifier = named("primary")) { FooViewModel(get()) }
    viewModel(qualifier = named("secondary")) { FooViewModel(get()) }

Like this in Activity:

    private val primaryFooViewModel by viewModel<FooViewModel>(qualifier = named("primary"))
    private val secondaryFooViewModel by viewModel<FooViewModel>(qualifier = named("secondary"))

And like this in Fragment:

    private val primaryFooViewModel by viewModel<FooViewModel>(qualifier = named("secondary"))

Expected behavior
Separate instances are injected according to qualifier value.

Koin project used and used version (please complete the following information):
koin-core, koin-androidx-viewmodel, koin-android version 2.0.0-GA

@arnaudgiuliani arnaudgiuliani added android koin-androidx type:issue status:checking currently in analysis - discussion or need more detailed specs labels May 15, 2019
@arnaudgiuliani arnaudgiuliani modified the milestone: 2.0.0 May 15, 2019
@arnaudgiuliani
Copy link
Member

the qualifier used here should be passed as a tag for the Android ViewModelFatory

@arnaudgiuliani
Copy link
Member

Should be fixed in 2.0.0-GA3

@arnaudgiuliani
Copy link
Member

Reopen it if any problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android status:checking currently in analysis - discussion or need more detailed specs type:issue
Projects
None yet
Development

No branches or pull requests

2 participants