Comments (6)
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.
@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.
@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.
@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.
Current recommendation for this is put a SingletonComponent interface in your base module and an impl of it in your app.
from kotlin-inject.
@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)
- Unclear error message for scoped provider HOT 2
- Providing a function instead of property seems to not always work HOT 1
- Ability to bind Implementaion with Interface HOT 1
- Calling scoped suspending provider should create singleton instance HOT 6
- Custom component and scope support like in Dagger 2
- Generated code is not accessible from commonMain HOT 5
- Search for a covariant type when checking if a component's abstract property has been implemented
- can't build the project HOT 1
- Error while compiling project HOT 5
- Feature request - support deferring to superclass component properties HOT 2
- Typealiases lead to KSP StackOverflowException
- Scope annotations aren't picked up when scanning superclasses
- Expect Actual Ancestor Components and Common Descendant Components HOT 5
- Kotlin Delegation Support? HOT 4
- Interface Bindings HOT 3
- Support @IntoSet for superclass HOT 1
- Names clash for properties in component with multiple super types HOT 2
- Component with an Int literal property name is used as an Int value
- Implemented function still considered abstract HOT 1
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 kotlin-inject.