-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop using Retrofit BaseUrl for switching REST api endpoint #111
Comments
Retrofit2 is released 🎉 |
For this situation, I'm using a Configuration class. Which can inject to ApiModule to get Retrofit a base url. With this, we can easy to change configuration environment for each build type as well as function testing. Interceptor is an interesting way, but I think using Configuration is more natural. |
The thing is that I'd like to be able to change endpoint url without restarting the app, I think, recreation of Retrofit is the best option in such case. |
Change endpoint url without restart app is really cool, but recreation of Retrofit with clean code in mind is quite hard. Looking forward the solution for this. |
Recreation can be done via Dagger, we'll either recreate only Retrofit or also objects that depend on it, not sure yet |
@artem-zinnatullin This issue turns out to be a little bit more complicated that it seems to be. Even if you re-create the object graph (with new retrofit instance pointing to another URL), you need to propagate / re-inject dependencies into targets (views, presenters, etc.). Otherwise, behaviour of the app will be unpredictable. The most obvious, but not elegant solution is to restart process by using: https://github.com/JakeWharton/ProcessPhoenix. If process will be restarted, we won't have stale instances of dependencies within application. What do you think? |
Noo, process restart is not an option because it won't work in UI tests On 14 Oct 2016 6:18 pm, "Araz Abishov" [email protected] wrote:
|
@artem-zinnatullin would you accept Interceptor solution as per conversation in square/retrofit#1652 ? Particularly: https://gist.github.com/swankjesse/8571a8207a5815cca1fb |
@Yurii-Laguta yep, we can start with that, would be better to re-create Retrofit on base URL change though |
See square/retrofit#1652
The text was updated successfully, but these errors were encountered: