I'm using dagger 2 and retrofit2 in a project that can change the country configurations and also the URL of the country you are pointing at for requesting data.
Is there any way Dagger2 can create again a Retrofit instance which will include the new URL?
So the idea is to restart the dependency of Retrofif whenever the user changes its country.
Finally a solution that works. However I am not 100% sure about its performance cost.
Knowing that a user won't change the country too often or perhaps only once after installing the app, we can call again to DaggerAppComponent.builder().... .build() in the Custom Application class or whenever it is defined in a project. So once it instantiates again retrofit It will take the new URL.
As I said, this may have a cost of performance but this won't happen too often.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With