rx.Observable.serialize()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(1.3k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中rx.Observable.serialize()方法的一些代码示例,展示了Observable.serialize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.serialize()方法的具体详情如下:
包路径:rx.Observable
类名称:Observable
方法名:serialize

Observable.serialize介绍

[英]Forces an Observable's emissions and notifications to be serialized and for it to obey the Rx contract in other ways.

It is possible for an Observable to invoke its Subscribers' methods asynchronously, perhaps from different threads. This could make such an Observable poorly-behaved, in that it might try to invoke onCompleted or onError before one of its onNext invocations, or it might call onNext from two different threads concurrently. You can force such an Observable to be well-behaved and sequential by applying the serialize method to it.

Scheduler: serialize does not operate by default on a particular Scheduler.
[中]强制可观测对象的发射和通知序列化,并以其他方式遵守接收合同。
Observable可以异步调用其订阅者的方法,可能来自不同的线程。这可能会使这样一个可观察的对象表现不佳,因为它可能会尝试在其onNext调用之一之前调用onCompleted或onError,或者可能会同时从两个不同的线程调用onNext。通过对这样的可观察对象应用serialize方法,可以强制其行为良好且连续。
调度程序:serialize默认情况下不会在特定调度程序上运行。

代码示例

代码示例来源:origin: io.reactivex/rxjava-reactive-streams

public PublisherAdapter(final Observable<T> observable) {
  this.observable = observable.serialize();
}

代码示例来源:origin: leeowenowen/rxjava-examples

o.serialize().subscribe(new Action1<Integer>() {
 @Override
 public void call(Integer integer) {

相关文章

Observable类方法