Pablo
03/12/2025, 6:59 PMsingle<ApiService> {
Retrofit.Builder()
.baseUrl("<https://myurl.es>")
.addConverterFactory(JacksonConverterFactory.create())
.addConverterFactory(ScalarsConverterFactory.create())
.build()
.create(ApiService::class.java)
}
The issue is that I need to parametrize the baseUrl to retrofit, because the user can change it with a textfield. How can I tell Koin that must initialize this singleton for retrofit with a dinamically passed variable? I only found very complex samples for doing this using factory instead of singleton, and doing it with field injection instead of constructor injection, so I hope there is a simpler way.withoutclass
03/12/2025, 7:02 PMPablo
03/12/2025, 7:22 PMPablo
03/12/2025, 7:22 PMPablo
03/12/2025, 7:22 PMwithoutclass
03/12/2025, 7:25 PMfactory
and the retrofit.newBuilder()
api. Keep your retrofit as a singleton, then in your Api definition use a factory where you can pass the base urlPablo
03/12/2025, 9:37 PMwithoutclass
03/13/2025, 1:57 PMCXwudi
03/14/2025, 4:59 AMPablo
03/14/2025, 7:33 AMwithoutclass
03/14/2025, 2:32 PMwithoutclass
03/14/2025, 2:33 PMCXwudi
03/14/2025, 3:04 PM