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 ...