-
-
Notifications
You must be signed in to change notification settings - Fork 691
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
Beta 2 - ViewModel registration must have definition #394
Comments
Are you (consiously) trying to use the (experimental) reflection-based API? |
Yes, I am. It worked fine in v1.0.0 (and even in v0.x versions), however it's gone in v2.x. The reflection based system works perfectly fine for me as I use zero-argument constructors and every injection happens as class body property injection, e.g.:
|
I faced same issue but resolved it with this |
@waqas117 your solution would be perfect if the trouble was with injection - however my issue is not with that, but registering the dependency. Since this step does not involve for a moment the LifecycleOwner or ComponentActivity, it's not a solution. |
reflection api has been removed from viewmodel package to avoid too much wrong usage |
@arnaudgiuliani An understandable step, however some indication would've been useful - maybe in the migration guide, as a footnote? |
yep, and also because API is still really experimental |
won't fix in code, but rather will add documentation for that |
Describe the bug
In 2.0.0 beta 1 and 2, registering a ViewModel via
viewModel<vmType>()
is not possible - it requires a specified definition. Documentation says the old, definition-less, type-specifying variant should still work.To Reproduce
Steps to reproduce the behavior:
viewModel<MyViewModel>()
definition
is requiredviewModel<MyViewModel>()
withviewModel { MyViewModel() }
Expected behavior
I'd expect
viewModel<MyViewModel>()
to be an acceptable statement within amodule
Koin project used and used version (please complete the following information):
koin-androidx-viewmodel version 2.0.0-beta-1
koin-androidx-viewmodel version 2.0.0-beta-2
The text was updated successfully, but these errors were encountered: