本文整理了Java中io.reactivex.Observable.switchOnNextDelayError()
方法的一些代码示例,展示了Observable.switchOnNextDelayError()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Observable.switchOnNextDelayError()
方法的具体详情如下:
包路径:io.reactivex.Observable
类名称:Observable
方法名:switchOnNextDelayError
[英]Converts an ObservableSource that emits ObservableSources into an ObservableSource that emits the items emitted by the most recently emitted of those ObservableSources and delays any exception until all ObservableSources terminate.
switchOnNext subscribes to an ObservableSource that emits ObservableSources. Each time it observes one of these emitted ObservableSources, the ObservableSource returned by switchOnNext begins emitting the items emitted by that ObservableSource. When a new ObservableSource is emitted, switchOnNext stops emitting items from the earlier-emitted ObservableSource and begins emitting items from the new one.
The resulting ObservableSource completes if both the main ObservableSource and the last inner ObservableSource, if any, complete. If the main ObservableSource signals an onError, the termination of the last inner ObservableSource will emit that error as is or wrapped into a CompositeException along with the other possible errors the former inner ObservableSources signalled. Scheduler: switchOnNextDelayError does not operate by default on a particular Scheduler.
[中]将发出ObservableSource的ObservableSource转换为发出最近发出的ObservableSource发出的项目的ObservableSource,并延迟任何异常,直到所有ObservableSource终止。
switchOnNext订阅发出ObservableSource的ObservableSource。每次它观察到其中一个发出的ObservableSource时,switchOnNext返回的ObservableSource开始发出该ObservableSource发出的项。当发出新的ObservableSource时,switchOnNext停止从先前发出的ObservableSource发出项目,并开始从新的ObservableSource发出项目。
如果主可观测资源和最后一个内部可观测资源(如果有)都已完成,则生成的可观测资源将完成。如果主可观测资源发出一个错误信号,最后一个内部可观测资源的终止将发出该错误,或者将其包装成复合异常,以及前一个内部可观测资源发出的其他可能错误。调度程序:switchOnNextDelayError默认情况下不会在特定调度程序上运行。
代码示例来源:origin: ReactiveX/RxJava
@Test
public void scalarMapDelayError() {
Observable.switchOnNextDelayError(Observable.just(Observable.just(1)))
.test()
.assertResult(1);
}
代码示例来源:origin: ReactiveX/RxJava
@SchedulerSupport(SchedulerSupport.NONE)
public static <T> Observable<T> switchOnNextDelayError(ObservableSource<? extends ObservableSource<? extends T>> sources) {
return switchOnNextDelayError(sources, bufferSize());
代码示例来源:origin: redisson/redisson
@SchedulerSupport(SchedulerSupport.NONE)
public static <T> Observable<T> switchOnNextDelayError(ObservableSource<? extends ObservableSource<? extends T>> sources) {
return switchOnNextDelayError(sources, bufferSize());
代码示例来源:origin: ReactiveX/RxJava
@Test
public void switchOnNextDelayError() {
PublishSubject<Observable<Integer>> ps = PublishSubject.create();
TestObserver<Integer> to = Observable.switchOnNextDelayError(ps).test();
ps.onNext(Observable.just(1));
ps.onNext(Observable.range(2, 4));
ps.onComplete();
to.assertResult(1, 2, 3, 4, 5);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void switchOnNextDelayErrorBufferSize() {
PublishSubject<Observable<Integer>> ps = PublishSubject.create();
TestObserver<Integer> to = Observable.switchOnNextDelayError(ps, 2).test();
ps.onNext(Observable.just(1));
ps.onNext(Observable.range(2, 4));
ps.onComplete();
to.assertResult(1, 2, 3, 4, 5);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void switchOnNextDelayErrorWithError() {
PublishSubject<Observable<Integer>> ps = PublishSubject.create();
TestObserver<Integer> to = Observable.switchOnNextDelayError(ps).test();
ps.onNext(Observable.just(1));
ps.onNext(Observable.<Integer>error(new TestException()));
ps.onNext(Observable.range(2, 4));
ps.onComplete();
to.assertFailure(TestException.class, 1, 2, 3, 4, 5);
}
内容来源于网络,如有侵权,请联系作者删除!