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 Factory Methods

Until now, we have used method extraction technique to simplify Consumers (actions), .flatMap(), and other similar calls. However, there is a slight difference when we are creating a method to create something that can be used completely independently in multiple places, as opposed to a method that was just used to extract a tightly-coupled piece of code.

Such an approach is called a Factory Method pattern--it is basically a method that hides the complexity of object creation.

You can find more about the Factory Method pattern at https://en.wikipedia.org/wiki/Factory_method_pattern.

In our code, we have a few candidates for that and all of them create complex Observables that produce StockUpdate objects:

  • Financial ...

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