Replies: 1 comment 1 reply
-
| You can do this today by hiding your component behind an interface. interface NetworkComponent {
   val repo: Repo
}
@Component
abstract class NetworkComponentImpl : NetworkComponent {
  @Provides
  fun provideOkHttpClient(): OkHttpClient = { /* ... */ }
}
@Inject
class Repo(val httpClient: OkHttpClient)
@Component
abstract class DomainComponent(@Component val parent: NetworkComponent)but yeah there could be room for improvement here. There tricky part is knowing what to generate so that the transitive dependencies can still be constructed in a downstream component, which could be in another module. | 
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! Thanks for the wonderful library!
I wonder how hard would it be to have some providers allowed to be "internal", for example
I.e. in my setup (perhaps a multi-gradle-module one) I only want the component to "export"
Repoand hideOkHttpClient, which I want to provide only "internally", because while building it I still might want to use DI, as it could be helpful if my dependency building is complex, but in the end I don't want anything apart the final object to "leak" and be visible/usable on the consuming side. Trying to injectOkHttpClientin any child component would be an error in this case.This is what I very much miss in Dagger, perhaps
kotlin-injectcould have such a feature?Beta Was this translation helpful? Give feedback.
All reactions