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

A Place where things start getting ugly

At first, it might look like a reasonable approach to extract and reuse code. However, it doesn't scale beyond one such extraction. Let's say that we want to extract another block that's responsible for the StockUpdate item's persistence and retrieval:

.doOnNext(this::saveStockUpdate).onExceptionResumeNext(StorIOFactory.createLocalDbStockUpdateRetrievalObservable(this))

Similarly, we will extract a method that will ensure that items are saved in the local database and later retrieved:

private Observable<StockUpdate> addLocalItemPersistenceHandling(Observable<StockUpdate> observable) {return observable.doOnNext(this::saveStockUpdate)            .onExceptionResumeNext(StorIOFactory.createLocalDbStockUpdateRetrievalObservable ...

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