https://github.com/ReactiveX/RxJava/wiki/Observable-Utility-Operators
This page lists various utility operators for working with Observables:
Operators | introduce | 中文介绍 |
---|---|---|
materialize( ) | convert an Observable into a list of Notifications | 将可观察对象转换为通知列表 |
dematerialize( ) | convert a materialized Observable back into its non-materialized form | 与上一个操作相反,将通知列表或其他列表转回到非物质化 |
serialize( ) | force an Observable to make serialized calls and to be well-behaved | 强制可观察对象进行序列化调用并保持良好的行为 |
cache( ) | remember the sequence of items emitted by the Observable and emit the same sequence to future Subscribers | 记住可观察对象发出的项序列,并将相同的序列发出给未来的订阅者 |
observeOn( ) | specify on which Scheduler a Subscriber should observe the Observable | 指定观察者的线程,每次指定一次都会生效。,指定订阅服务器应该在哪个调度程序上观察可观察对象 |
subscribeOn( ) | specify which Scheduler an Observable should use when its subscription is invoked | 指定被观察者的线程,即数据源发生的线程。多次指定只有第一次有效。指定可观察对象在调用其订阅时应该使用哪个调度程序 |
doOnEach( ) | register an action to take whenever an Observable emits an item | 数据源(Observable)每发送一次数据,就调用一次。注册一个当被观察对象发出一个项时要执行的动作 |
doOnNext( ) | register an action to call just before the Observable passes an onNext event along to its downstream | 数据源每次调用onNext() 之前都会先回调该方法。在被观察对象将onNext事件传递到其下游之前,注册一个要调用的动作 |
doAfterNext( ) | register an action to call after the Observable has passed an onNext event along to its downstream | 数据源每次调用onNext() 之后都会调用该方法.在被观察对象将onNext事件传递到下游之后,注册一个要调用的动作 |
doOnCompleted( ) | register an action to take when an Observable completes successfully | 被观察者成功结束时会进行调用.注册一个被观察对象成功完成时要执行的操作 |
doOnError( ) | register an action to take when an Observable completes with an error | 被观察者出现Error错误时执行调用.注册一个在被观察对象出现错误时要执行的操作 |
doOnTerminate( ) | register an action to call just before an Observable terminates, either successfully or with an error | 之前,在被观察对象终止之前注册一个要调用的动作,可以是成功终止,也可以是出现错误终止 |
doAfterTerminate( ) | register an action to call just after an Observable terminated, either successfully or with an error | 之后,在被观察对象成功终止或出现错误时,注册一个要调用的动作 |
doOnSubscribe( ) | register an action to take when an observer subscribes to an Observable | 注册观察者订阅被观察对象时要执行的操作,比如我订阅的b站篮球up主,我就属于观察者Observer,篮球up主就是属于被观察者 |
finallyDo( ) | register an action to take when an Observable completes | 注册一个被观察对象完成时要执行的操作 |
doFinally( ) | register an action to call when an Observable terminates or it gets disposed | 注册一个在被观察终止或被释放时调用的动作 |
delay( ) | shift the emissions from an Observable forward in time by a specified amount | 延迟发射,将可观测到的数据在延迟一定时间发射 |
delaySubscription( ) | hold an Subscriber's subscription request for a specified amount of time before passing it on to the source Observable | 延迟订阅,在将订阅者的订阅请求传递给可观察数据源之前,将订阅者的订阅请求保存一段指定的时间 |
timeInterval( ) | emit the time lapsed between consecutive emissions of a source Observable | 发射一个可观测数据源连续发射之间的时间间隔 |
using( ) | create a disposable resource that has the same lifespan as an Observable | 创建一个与被观察者生命周期等同的一次性数据源 |
single( ) | if the Observable completes aftere emitting a single item,return that item, otherwise throw an exception | 如果可观察对象在发出单个项后完成,则返回该项,否则抛出异常 |
singleOrDefault( ) | if the Observable completes after emitting a single item, return that item, otherwise return a default item | 如果可观察对象在发出单个项后完成,则返回该项,否则返回默认项 |
repeat( ) | create an Observable that emits a particular item or sequence of items repeatedly | 创建一个可观察对象,重复发出特定的项目或项目序列 |
repeatWhen( ) | create an Observable that emits a particular item or sequence of items repeatedly, depending on the emissions of a second Observable | 创建一个可观察对象,根据第二个可观察对象的发射情况,重复发射特定的项目或项目序列 |