Error Handling Operators 错误处理
- Catch — recover from an onError notification by continuing the sequence without error
- Retry — if a source Observable sends an onError notification, resubscribe to it in the hopes that it will complete without error
Observable Utility Operators 通用操作
- Delay — shift the emissions from an Observable forward in time by a particular amount
- Do — register an action to take upon a variety of Observable lifecycle events
- Materialize/Dematerialize — represent both the items emitted and the notifications sent as emitted items, or reverse this process
- ObserveOn — specify the scheduler on which an observer will observe this Observable
- Serialize — force an Observable to make serialized calls and to be well-behaved
- Subscribe — operate upon the emissions and notifications from an Observable
- SubscribeOn — specify the scheduler an Observable should use when it is subscribed to
- TimeInterval — convert an Observable that emits items into one that emits indications of the amount of time elapsed between those emissions
- Timeout — mirror the source Observable, but issue an error notification if a particular period of time elapses without any emitted items
- Timestamp — attach a timestamp to each item emitted by an Observable
- Using — create a disposable resource that has the same lifespan as the Observable
subscribeOn(Schedulers.io())
subscribeOn会修改我们刚刚创建的Observable。在默认情况下Observable的所有代码,包括刚才说到的只有在被订阅之后才会执行的代码,都会在执行subscribe()方法的线程中运行。而通过subscribeOn()方法,这些代码可以在其他线程中执行。
observeOn(AndroidSchedulers.mainThread())
告诉RxJava我们要在UI线程中观察这个Observable