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

How Observables work

Before we do anything else, we need to study how an Observable sequentially passes items down a chain to an Observer. At the highest level, an Observable works by passing three types of events:

  • onNext(): This passes each item one at a time from the source Observable all the way down to the Observer.
  • onComplete(): This communicates a completion event all the way down to the Observer, indicating that no more onNext() calls will occur.
  • onError(): This communicates an error up the chain to the Observer, where the Observer typically defines how to handle it. Unless a retry() operator is used to intercept the error, the Observable chain typically terminates, and no more emissions will occur.

These three events are abstract methods in the Observer type, and we will cover some of the implementation later. For now, we will focus pragmatically on how they work in everyday usage.

In RxJava 1.0, the onComplete() event is actually called onCompleted().
主站蜘蛛池模板: 林口县| 鄂托克旗| 肇庆市| 鸡东县| 西乌珠穆沁旗| 册亨县| 广东省| 德江县| 万盛区| 绵阳市| 富蕴县| 连江县| 田阳县| 广平县| 崇信县| 忻城县| 石门县| 偏关县| 宿松县| 宁津县| 玉屏| 沁源县| 华坪县| 寿宁县| 喀喇| 科技| 武义县| 克什克腾旗| 台南县| 石城县| 忻城县| 石城县| 左云县| 阿勒泰市| 稷山县| 同江市| 兴城市| 阳高县| 石泉县| 开阳县| 天祝|