Pick the fix
Two repositories each get their own OkHttpClient, doubling connection pools. What's the fix?
Hint 1 of 1
Which binding needs to be shared?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Provide OkHttpClient from a SingletonComponent module annotated @Singleton
Correct. One shared client for the app.
Why not the others?
- B Mark both repositories @Singleton. The client binding is still unscoped, so each gets a new one.
- C Use @ViewModelScoped on the client. That still makes one per ViewModel.
- D Create the client in Application and pass it around manually. Works, but bypasses DI.