官术网_书友最值得收藏!

  • Learning RxJava
  • Thomas Nield
  • 258字
  • 2021-07-02 22:22:56

Basic Operators

In the previous chapter, you learned a lot about the Observable and Observer. We also covered a small number of operators, particularly map() and filter(), to understand the role of operators as well. But there are hundreds of RxJava operators we can leverage to express business logic and behaviors. We will cover operators comprehensively throughout much of this book, so you know which ones to use and when. Being aware of the operators available and combining them is critical to being successful using ReactiveX. You should strive to use operators to express business logic so your code stays as reactive as possible.

It should be noted that operators themselves are Observers to the Observable they are called on. If you call map() on an Observable, the returned Observable will subscribe to it. It will then transform each emission and in turn be a producer for Observers downstream, including other operators and the terminal Observer itself.

You should strive to execute as much logic as possible using RxJava operators, and you should use an Observer to receive the end product emissions that are ready to be consumed. Try not to cheat or get creative by extracting values out of the Observable chain, or resort to blocking processes or imperative programming tactics. When you keep algorithms and processes reactive, you can easily leverage the benefits of reactive programming such as lower memory usage, flexible concurrency, and disposability.

In this chapter, we will cover the following topics:

  • Suppressing operators
  • Transforming operators
  • Reducing operators
  • Error-recovery operators
  • Action operators
主站蜘蛛池模板: 招远市| 泸定县| 同江市| 巧家县| 蒲城县| 南郑县| 青海省| 香港 | 芦山县| 湘西| 远安县| 石景山区| 新竹县| 辰溪县| 长宁区| 麻江县| 桦南县| 沅江市| 定州市| 汶上县| 志丹县| 宣武区| 嘉荫县| 防城港市| 平江县| 嘉禾县| 宜川县| 兴海县| 昂仁县| 当雄县| 中西区| 抚远县| 阿克陶县| 互助| 郴州市| 浦城县| 舒城县| 苏尼特右旗| 青河县| 逊克县| 始兴县|