Code Monkey home page Code Monkey logo

Comments (1)

Chang-Eric avatar Chang-Eric commented on August 20, 2024 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.