I'm using dagger hilt
as a dependency injection framework in my project, however, I have this situation where I need to provide Retrofit
instance. Normally I do it using the @Provides
annotation.
@Provides
@Singleton
fun provideRetrofit(
okHttpClient: OkHttpClient,
scalarsConverterFactory: ScalarsConverterFactory,
): Retrofit = Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(scalarsConverterFactory)
.client(okHttpClient)
.build()
But now I came to a situation where I need to have a dynamic BASE_URL
. In normal cases when the class is created by me, I use the @AssestedFactory
and @AssestedInject
annotations.
How to use the @AssestedFactory
to provide a dynamic BASE_URL
in my situation.