How to implement RxJava 2 exponential backoff retry only when internet is available

Pablo A. Martínez
Pablo A. Martínez Andrés
4 min readSep 7, 2018

--

Usually when developing Android apps I implement an user screen where the user can refresh the screen by means of pressing a button or pulling some view, etc…

This action triggers an internet call that is wrapped by Retrofit returning a Single observable, and while this call is going on we disable the “refresh feature” of the screen to avoid duplicating refresh actions until the previous one is finished. Thus if connections succeeds data is displayed on the screen and if it fails an error…

--

--

Entrepreneur & CEO @GreenLionSoft · Android Lead · Home of @MadridMBC · Android, OpenSource and OpenData promoter · Runner · Traveller