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

Creating transformer classes

Sometimes, it is worthwhile to move the extracted transformer to its own class. In most cases, this will be code that can be reused in multiple places between multiple Observables. In this section, we will see how we can do that to the persistence code, and we will explore a few additional examples for file-based caching and measure the timing of the execution.

For starters, as an exercise, we will move the code that handles the persistence of StockUpdate items to a separate class.

First of all, let's create a Transformer class in packt.reactivestocks.storio :

package packt.reactivestocks.storio;import io.reactivex.ObservableTransformer;import packt.reactivestocks.StockUpdate;public class LocalItemPersistenceHandlingTransformer ...

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