I have an `:app` module and then a `network` modul...
# dagger
c
I have an
:app
module and then a
network
module. I want the network module to expose services like BooksService and LibraryService. Those two services require a OkHttpClient. I can also add a provider for the http client, but then okhttpClient provider is exposed to the app. Anyway to hide that "internal" dependency with dagger?
Copy code
networkModule's provider declaration:

@Provides
fun provideBooksService(okHttpClient: OkHttpClient): BooksService {
  return NetworkBackedBooksService(okHttpClient)
}

@Provides
fun provideLibraryService(okHttpClient: OkHttpClient): LibraryService {
  return NetworkBackedLibraryService(okHttpClient)
}

@Provides
fun providesHttpClient(): OkHttpClient {
  return //...
}
m
Would something like what’s described here work for you? https://www.zacsweers.dev/dagger-party-tricks-private-dependencies/
c
i just opened the link and the first example pretty much looks like what id want. CHEERS!
wow. this is exactly what i wanted. so glad i asked the question. thank you
j
If I remember correctly you can just use internal fun + @PublishedApi
c
oh. I'll try that as well just out of curiosity and report back. 😄
FWIW. I tried the PublishedApi suggestion and it didn't seem to work. Going to steal Zacs suggestion instead from the article 😄