io.reactivex.Flowable.switchMapDelayError()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(245)

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

Flowable.switchMapDelayError介绍

[英]Returns a new Publisher by applying a function that you supply to each item emitted by the source Publisher that returns a Publisher, and then emitting the items emitted by the most recently emitted of these Publishers and delays any error until all Publishers terminate.

The resulting Publisher completes if both the upstream Publisher and the last inner Publisher, if any, complete. If the upstream Publisher signals an onError, the termination of the last inner Publisher will emit that error as is or wrapped into a CompositeException along with the other possible errors the former inner Publishers signaled.

Backpressure: The operator honors backpressure from downstream. The outer Publisher is consumed in an unbounded manner (i.e., without backpressure) and the inner Publishers are expected to honor backpressure but it is not enforced; the operator won't signal a MissingBackpressureExceptionbut the violation may lead to OutOfMemoryError due to internal buffer bloat. Scheduler: switchMapDelayError does not operate by default on a particular Scheduler.
[中]通过将您提供的函数应用于返回发布服务器的源发布服务器发出的每个项目,然后发出这些发布服务器中最近发出的项目,并延迟任何错误,直到所有发布服务器终止,从而返回新发布服务器。
如果上游发布服务器和最后一个内部发布服务器(如果有)都已完成,则生成的发布服务器将完成。如果上游发布服务器发出onError信号,则最后一个内部发布服务器的终止将按原样发出该错误,或将该错误包装成CompositeException,以及前内部发布服务器发出的其他可能错误。
背压:操作员接受来自下游的背压。外部发布服务器以无限制的方式使用(即,没有背压),内部发布服务器应遵守背压,但不强制执行;操作员不会发出MissingBackPressureException的信号,但由于内部缓冲区膨胀,违规可能导致OutOfMemoryError。调度程序:switchMapDelayError默认情况下不会在特定调度程序上运行。

代码示例

代码示例来源:origin: ReactiveX/RxJava

@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Flowable<R> switchMapDelayError(Function<? super T, ? extends Publisher<? extends R>> mapper) {
  return switchMapDelayError(mapper, bufferSize());

代码示例来源:origin: ReactiveX/RxJava

@SchedulerSupport(SchedulerSupport.NONE)
public static <T> Flowable<T> switchOnNextDelayError(Publisher<? extends Publisher<? extends T>> sources, int prefetch) {
  return fromPublisher(sources).switchMapDelayError(Functions.<Publisher<? extends T>>identity(), prefetch);

代码示例来源:origin: ReactiveX/RxJava

@Test
public void switchMapDelayErrorEmptySource() {
  assertSame(Flowable.empty(), Flowable.<Object>empty()
      .switchMapDelayError(new Function<Object, Publisher<Integer>>() {
        @Override
        public Publisher<Integer> apply(Object v) throws Exception {
          return Flowable.just(1);
        }
      }, 16));
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public Publisher<Long> createPublisher(long elements) {
    return
      Flowable.just(1).switchMapDelayError(Functions.justFunction(
          Flowable.fromIterable(iterate(elements)))
      )
    ;
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Test
public void switchMapDelayErrorJustSource() {
  Flowable.just(0)
  .switchMapDelayError(new Function<Object, Publisher<Integer>>() {
    @Override
    public Publisher<Integer> apply(Object v) throws Exception {
      return Flowable.just(1);
    }
  }, 16)
  .test()
  .assertResult(1);
}

代码示例来源:origin: redisson/redisson

@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Flowable<R> switchMapDelayError(Function<? super T, ? extends Publisher<? extends R>> mapper) {
  return switchMapDelayError(mapper, bufferSize());

代码示例来源:origin: redisson/redisson

@SchedulerSupport(SchedulerSupport.NONE)
public static <T> Flowable<T> switchOnNextDelayError(Publisher<? extends Publisher<? extends T>> sources, int prefetch) {
  return fromPublisher(sources).switchMapDelayError(Functions.<Publisher<? extends T>>identity(), prefetch);

相关文章

Flowable类方法