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

Add example of library usage with Retrofit #68

Closed
pwittchen opened this issue Jun 9, 2016 · 5 comments
Closed

Add example of library usage with Retrofit #68

pwittchen opened this issue Jun 9, 2016 · 5 comments

Comments

@pwittchen
Copy link
Owner

Add example of library usage with Retrofit and update documentation.

It's related to issue #49.

@YuriHeupa
Copy link

Also waiting for this!

@Rainer-Lang
Copy link

Me too.

@pwittchen
Copy link
Owner Author

I remember about that. I just need to find some time for this. Recently, I've bumped library version and added new updates like support for Android N and better network monitoring, which are crucial enhancements in this project. Providing this example will be next on my list. :)

@epicstar
Copy link

epicstar commented Aug 11, 2016

I'm currently using this library with Retrofit + RxJava using Observable#retryWhen() using one of the older versions of ReactiveNetwork: https://github.com/rectangle-dbmi/Realtime-Port-Authority/blob/7.0.2/app/src/main/java/rectangledbmi/com/pittsburghrealtimetracker/BusMapFragment.java#L555

This will work when both of these two criteria are true:

  1. the restish server cannot be reached (the retrofit observable throws an IOException)
  2. when it is determined that this is due to a lost data connection on the phone side (though there is a bug where I'm not looking at SocketTimeoutException when I should... in other words, the app currently doesn't account for when the restish server is down and also thinks the phone connection is down... a bug)

I know that maybe people will be checking internet connection first then do their retrofit call, but I did my logic in reverse. My observable chain is currently running in an interval, and I wanted my interval to stop polling the restish server when the internet is gone, and restart the second when the internet is back. The lines of code above do exactly, that.

I hope that in the future, for the next rewritten feature of my app, I can a stack clicks for network calls when internet on the phone is somehow down and retry those click actions deriving from the logic above, too.

Currently, the rest of the code is a bit scary (because of my failure to use one of the MVVM patterns of Android... which will be fixed). I will be changing to the newer version of the library later AND will be using the internetConnectivityObservable when I have the time to change it.

@pwittchen pwittchen removed their assignment Nov 14, 2016
@pwittchen
Copy link
Owner Author

I've added a simple example here: https://github.com/pwittchen/ReactiveNetwork#integration-with-retrofit.
It's valid for RxJava2.x version.

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

4 participants