Is creating multiple Retrofit service instances ok...
# android-architecture
u
Is creating multiple Retrofit service instances okay? One per module; lets say 20 overall; given the okhttp instance is shared? Or should I rather strive for a single big retrofit instance and have it extend some partial interfaces, so it then can get injected behind it?
s
I can't see any drawbacks in using multiple retrofit services if they share the same http client, I would even argue it's the opposite. I allows to separate your entities API's in several interfaces. 🤷
o
^ agreed
u
ok, but you do share the rest adapters? i.e.
val restAdapter = Retrofit.Builder()...build()
?
s
You'll have one retrofit instance (if you have one base URL) and several generated services.
u
yea, I thought retrofit instances were cheap so I spammed them as the generated services, only sharing the okhttp
605 Views