Skip to content
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

Open
artem-zinnatullin opened this issue Mar 7, 2016 · 9 comments
Open
Assignees
Milestone

Comments

@artem-zinnatullin
Copy link
Owner

See square/retrofit#1652

@artem-zinnatullin artem-zinnatullin self-assigned this Mar 7, 2016
@artem-zinnatullin artem-zinnatullin added this to the v1.0 milestone Mar 7, 2016
@vanniktech
Copy link
Contributor

Retrofit2 is released 🎉

@lenguyenthanh
Copy link
Contributor

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.

@artem-zinnatullin
Copy link
Owner Author

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.

See square/retrofit#1652

@lenguyenthanh
Copy link
Contributor

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.

@artem-zinnatullin
Copy link
Owner Author

Recreation can be done via Dagger, we'll either recreate only Retrofit or also objects that depend on it, not sure yet

@arazabishov
Copy link
Contributor

arazabishov commented Oct 14, 2016

@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?

@artem-zinnatullin
Copy link
Owner Author

Noo, process restart is not an option because it won't work in UI tests
since they run in same process (instrumentation API).

On 14 Oct 2016 6:18 pm, "Araz Abishov" [email protected] wrote:

@artem-zinnatullin https://github.com/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). 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?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#111 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA7B3MLqv5R6hjLxIp4vOZgyNykjx7HQks5qz51VgaJpZM4Hq3wd
.

@YuraLaguta
Copy link

YuraLaguta commented Oct 26, 2017

@artem-zinnatullin would you accept Interceptor solution as per conversation in square/retrofit#1652 ? Particularly: https://gist.github.com/swankjesse/8571a8207a5815cca1fb
This issues blocks #208

@artem-zinnatullin
Copy link
Owner Author

@Yurii-Laguta yep, we can start with that, would be better to re-create Retrofit on base URL change though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants