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

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
主站蜘蛛池模板: 江门市| 杭锦旗| 茂名市| 桂东县| 南岸区| 菏泽市| 灵寿县| 遂溪县| 射洪县| 罗源县| 东丰县| 普兰店市| 霸州市| 五河县| 杭锦后旗| 石泉县| 东兰县| 漳州市| 崇阳县| 清苑县| 南陵县| 饶河县| 莱阳市| 团风县| 松阳县| 若尔盖县| 田林县| 乌鲁木齐市| 永寿县| 平阴县| 商河县| 屏山县| 乌鲁木齐县| 宜君县| 当雄县| 三穗县| 康定县| 隆德县| 普陀区| 合江县| 宜宾县|