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

Support the key with viewModel #1375

Closed
allen-hsu opened this issue Jun 30, 2022 · 4 comments
Closed

Support the key with viewModel #1375

allen-hsu opened this issue Jun 30, 2022 · 4 comments
Labels

Comments

@allen-hsu
Copy link

allen-hsu commented Jun 30, 2022

Is your feature request related to a problem? Please describe.
Hi, because the ViewModel provider has the function (ViewModelProvider.get(key, clazz)) that can let you pass the key to ViewModel provide in order to get a different ViewModel with a different key, I want to raise this PR, and according to this :
#213.

Describe the solution you'd like
Add the key variable to every get ViewModel function. like this PR #1373

@arnaudgiuliani
Copy link
Member

Yes can be interesting. But from the Koin perspective, you can use a qualifier that do the same. Could it answer you case?

@arnaudgiuliani arnaudgiuliani added the question Usage question label Aug 26, 2022
@heitor-gia
Copy link

@arnaudgiuliani I believe a qualifier would not be able to do the same once you could use multiple instances of the same ViewModel class for different views simultaneously, attaching them by a key.

This answer #782 (comment) used to work in previous versions, but probably the library's internal logic has changed since then.

Adding the possibility of setting a key to creating multiple instances from a single definition would help a lot in cases where you have multiple stateful components that share the same type o ViewModel in a list, like in a feed, for example.

@stale
Copy link

stale bot commented Feb 25, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status:wontfix label Feb 25, 2023
@stale stale bot closed this as completed Mar 5, 2023
@arnaudgiuliani
Copy link
Member

this has been fixed for API in 3.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants