Comments (1)
I don't think we can add this as a feature to Hilt since it basically subverts the notion of what @Singleton
means since now those objects can be instantiated more than once (and you could have multiple instances still around if something else is holding on to the previous instance).
For your particular solution, besides the obvious issue of this reflecting on internal Hilt implementation details that aren't guaranteed, you should be careful about code obfuscation. Also, as alluded to above, this doesn't change that existing things may already have references to the old component that won't be dropped. So any existing activity, fragment, service, etc, won't be updated immediately. You might be fine with that, but you may also consider that weird things can happen on configuration change. For example, if the ApplicationComponent is switched and then a configuration change happens, the new activity would use the new ApplicationComponent while any ViewModel created before that would not because ViewModels are retained through configuration change. This could cause unexpected situations since your Activity would be using different singletons than your ViewModel. So overall, I wouldn't recommend this pattern.
from dagger.
Related Issues (20)
- Subcomponent MembersInjector error in 2.51 HOT 1
- Does Hilt always execute app module during instrumented test? HOT 3
- [KSP] Dagger-KSP does not see typealiased dagger annotations HOT 3
- Cannot invoke getAnnotationValue because "annotation" is null HOT 14
- Creator-less subcomponents are not visible to modules HOT 1
- Suggestion to add isInit() api to dagger.Lazy HOT 1
- [Error] : java.lang.ClassNotFoundException: Didn't find class "com.myproject.MainApplication" on path: DexPathList HOT 1
- K2 KAPT (aka KAPT4) doesn't like inline/reified. HOT 3
- [KSP2] ClassCastException: class KSClassDeclarationEnumEntryImpl cannot be cast to class XEnumEntry HOT 2
- Hilt: Injection not working in BroadcastReceiver HOT 4
- Assisted injection appears to not work correctly in some cases HOT 3
- [Dagger/MissingBinding] com.xxx.onboarding.presentation.otp.LoginViewModel cannot be provided without an @Inject constructor or an @Provides-annotated method. public abstract static class SingletonC implements SemaaiApplication_GeneratedInjector HOT 1
- Hilt Class Generation Fails After Upgrading to AGP 8.5.1 from 8.0.1 HOT 6
- Issue with Dagger Hilt Upgrade from 2.48 to 2.49 - Unable to Load Class JavacBasicAnnotationProcessor HOT 1
- Way to replace a dependency created using Constructor Injection for all tests using Hilt. HOT 4
- After updating from 2.51.1 to 2.52, my GWT application does not compile HOT 14
- NPE On Lazy Dagger
- [KSP] Component processing is not deferred if there are unresolved symbols in the current round HOT 3
- [KAPT] - Issue build type release AGP 8.4.0 - 8.5.2 Kotlin 1.9.24 and Dagger 2.52
- SomeClass$LazyClassKeyProviders.class generated by Dagger/Hilt is not deterministic
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dagger.