- Learning RxJava
- Thomas Nield
- 161字
- 2021-07-02 22:22:51
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().
推薦閱讀
- INSTANT Mock Testing with PowerMock
- C語言程序設計
- 機械工程師Python編程:入門、實戰與進階
- 零基礎學Python數據分析(升級版)
- QTP自動化測試進階
- Creating Mobile Apps with jQuery Mobile(Second Edition)
- 匯編語言編程基礎:基于LoongArch
- 時空數據建模及其應用
- Mastering JavaScript
- 軟件測試技術
- Android技術內幕(系統卷)
- 和孩子一起學編程:用Scratch玩Minecraft我的世界
- Building Clouds with Windows Azure Pack
- Python Business Intelligence Cookbook
- 程序員的算法趣題2