O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Offline fallback for StockUpdate entries

Now, all the tools needed to load StockUpdate entries from the database for offline viewing are available.

To plug in the database reading functionality for offline use, we will use .onExceptionResumeNext() as we discussed previously; it will be used to catch the error when Internet connection fails and resume the loading of stream items from SQLite.

.onExceptionResumeNext() should be inserted just after this call because we don't want to save saved entries again:

.doOnNext(this::saveStockUpdate)

So, the newly inserted call will look like this in the existing flow:

.doOnNext(this::saveStockUpdate).onExceptionResumeNext(...).observeOn(AndroidSchedulers.mainThread()).subscribe(stockUpdate -> {

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required