There is scenario, in my staging app where I need to change my base url provided by user. But issue is I have injected retrofit object using dagger(Using @Provides annotation). Now is it right to re inject my DaggerAppComponent or how should I have been proceeded.
s
satyan
03/12/2020, 9:49 AM
You could use an OkHttp Interceptor to intercept requests and set the base URL.
Saving the current base url in sharedpreferences / cache / whatever.
s
Saket Poddar
03/12/2020, 9:54 AM
But I need to reinject okhttpClient it right?
s
satyan
03/12/2020, 9:54 AM
No, you’ll inject one okHttpClient with this interceptor
satyan
03/12/2020, 9:56 AM
And if you want to only change the base URL base on user input for staging you could inject a dummy version for production and a version which would change the url for staging