Giter Site home page Giter Site logo

Comments (6)

evant avatar evant commented on June 8, 2024

That error is expected, you can only used scoped provides in a component that's scopped in the same scope, in your example, you should move : StockMeHttpClientProvider to SingletonComponent

from kotlin-inject.

devanshu6445 avatar devanshu6445 commented on June 8, 2024

@evant But i am creating a SingletonComponent so that i can scope any dependency to be singleton and SingletonComponent exists in a lower level module and why is it possible to only scope non Provides dependencies to parent Component?

from kotlin-inject.

evant avatar evant commented on June 8, 2024

@Provides means 'this component is creating the dependency', if it's scoped the component has to have the same scope to make sure it has the correct lifetime. You could re-recreate CoreDataLayerComponent multiple times and you'd want your singleton to live longer than that, so it can't be the owner.

from kotlin-inject.

devanshu6445 avatar devanshu6445 commented on June 8, 2024

@evant Okay, got it. But i think it be good to have something through which we can scope our higher level module's dependencies to lower level module's but are not provided by the higher level module's scope but want to scope it to lower level module's scope. So that the lower level doesn't become cluttered with all the providers in my case Singletons.
Right now to scope a dependency to a common Component we have to we have two different direction either to put the SIngletonComponent in the app module for @Provides and for @Inject in lower level modules.
something like InstallIn in hilt.
If there exits some other method for achieving this, Please let me know.

from kotlin-inject.

evant avatar evant commented on June 8, 2024

Current recommendation for this is put a SingletonComponent interface in your base module and an impl of it in your app.

from kotlin-inject.

devanshu6445 avatar devanshu6445 commented on June 8, 2024

@evant I tried it but getting the @Provides with scope: `in`.stock.core.di.ApplicationScope cannot be provided in an unscoped component. Is it possible in future tohave something where dependencies can be marked with @Provides outside of component like Hilt

from kotlin-inject.

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.