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

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
主站蜘蛛池模板: 沙田区| 天津市| 印江| 报价| 石狮市| 瑞丽市| 朝阳区| 盖州市| 甘泉县| 黄龙县| 阿克陶县| 乌兰浩特市| 广宁县| 长武县| 平谷区| 调兵山市| 东乌珠穆沁旗| 洞口县| 蒙山县| 信宜市| 保靖县| 资溪县| 长乐市| 乌拉特前旗| 五华县| 泗阳县| 武川县| 迭部县| 元阳县| 沁阳市| 灵石县| 扎囊县| 高安市| 大关县| 三明市| 自贡市| 时尚| 邵阳市| 永平县| 谷城县| 大厂|