-
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
ContributesAndroidInjector support for androidx.lifecycle.ViewModel #1271
Comments
Also wondering this same thing |
+1 |
We need to think through a few things, but the short answer is yes. |
Is there a timeline on that? |
Would be really useful. Already got burned by this when implemented such injection myself. It turns out, depending on how/when you inject Fragment (in my case), dagger may "help" retain a "cleared" It would also be extremely convenient if dagger could generate ViewModel Factories. From what I understand, the thing is a necessary (evil) piece of boilerplate code required by the framework. It has no other development value. Dagger could derive Factory implementation from injectable |
See my comment here, you can create that factory easily yourself. |
Resolves google#1652 Resolves google#1619 Resolves google#1248 Resolves google#1489 Resolves google#1444 Resolves google#1313 Resolves google#1264 Enables better support for newer androidx subprojects like google#1271, but I feel we need to start somewhere. This unblocks that by making the initial move to androidx as a namespace, and then splitting up newer artifacts out of this (and progressively making dagger-android-support increasingly just a shim that delegates to them) is a healthy approach.
Update imports and dependencies to use AndroidX APIs. For backwards compatibility, produce two new artifacts, "dagger-android-legacy" and "dagger-android-support-legacy" that are dejetified artifacts of the AndroidX versions. Resolves #1652 Resolves #1619 Resolves #1489 Resolves #1444 Resolves #1313 Resolves #1271 Resolves #1248 Resolves #1264 Co-authored-by: Zac Sweers <zsweers@slack-corp.com> RELNOTES=Migrate dagger-android to AndroidX. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=291051989
Update imports and dependencies to use AndroidX APIs. For backwards compatibility, produce two new artifacts, "dagger-android-legacy" and "dagger-android-support-legacy" that are dejetified artifacts of the AndroidX versions. Resolves #1652 Resolves #1619 Resolves #1489 Resolves #1444 Resolves #1313 Resolves #1271 Resolves #1248 Resolves #1264 Co-authored-by: Zac Sweers <zsweers@slack-corp.com> RELNOTES=Migrate dagger-android to AndroidX. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=291051989
I'm closing this since with the release of Hilt and the Jetpack extension for ViewModels using Hilt, I think this feature request for dagger.android is unlikely to be done. |
This is what @Chang-Eric is referring to: https://developer.android.com/training/dependency-injection/hilt-jetpack#viewmodels Sadly I wish there was a "vanilla" Dagger (aka w/out dagger-android or Hilt) way of doing this. |
Vanilla Dagger is platform agnostic. That's why it is vanilla 😉 |
Yeah I was complaining about ViewModel implementation, not Dagger =) It's a bummer they didn't give us constructor access. |
is there any plan for support androidx.lifecycle.ViewModel with @ContributesAndroidInjector?
The text was updated successfully, but these errors were encountered: