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

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

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

Flowable.concatMapCompletable介绍

[英]Maps the upstream items into CompletableSources and subscribes to them one after the other completes.

Backpressure: The operator expects the upstream to support backpressure. If this Flowable violates the rule, the operator will signal a MissingBackpressureException. Scheduler: concatMapCompletable does not operate by default on a particular Scheduler.
[中]

代码示例

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

/**
 * Maps the upstream items into {@link CompletableSource}s and subscribes to them one after the
 * other completes.
 * <p>
 * <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/concatMap.png" alt="">
 * <dl>
 *  <dt><b>Backpressure:</b></dt>
 *  <dd>The operator expects the upstream to support backpressure. If this {@code Flowable} violates the rule, the operator will
 *  signal a {@code MissingBackpressureException}.</dd>
 *  <dt><b>Scheduler:</b></dt>
 *  <dd>{@code concatMapCompletable} does not operate by default on a particular {@link Scheduler}.</dd>
 * </dl>
 * <p>History: 2.1.11 - experimental
 * @param mapper the function called with the upstream item and should return
 *               a {@code CompletableSource} to become the next source to
 *               be subscribed to
 * @return a new Completable instance
 * @see #concatMapCompletableDelayError(Function)
 * @since 2.2
 */
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
@BackpressureSupport(BackpressureKind.FULL)
public final Completable concatMapCompletable(Function<? super T, ? extends CompletableSource> mapper) {
  return concatMapCompletable(mapper, 2);
}

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

@Override
  public Completable apply(Flowable<Object> f)
      throws Exception {
    return f.concatMapCompletable(
        Functions.justFunction(Completable.complete()));
  }
}

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

/**
 * Maps the upstream items into {@link CompletableSource}s and subscribes to them one after the
 * other completes.
 * <p>
 * <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/concatMap.png" alt="">
 * <dl>
 *  <dt><b>Backpressure:</b></dt>
 *  <dd>The operator expects the upstream to support backpressure. If this {@code Flowable} violates the rule, the operator will
 *  signal a {@code MissingBackpressureException}.</dd>
 *  <dt><b>Scheduler:</b></dt>
 *  <dd>{@code concatMapCompletable} does not operate by default on a particular {@link Scheduler}.</dd>
 * </dl>
 * @param mapper the function called with the upstream item and should return
 *               a {@code CompletableSource} to become the next source to
 *               be subscribed to
 * @return a new Completable instance
 * @since 2.1.11 - experimental
 * @see #concatMapCompletableDelayError(Function)
 */
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
@BackpressureSupport(BackpressureKind.FULL)
@Experimental
public final Completable concatMapCompletable(Function<? super T, ? extends CompletableSource> mapper) {
  return concatMapCompletable(mapper, 2);
}

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

@Test
public void mapperCrash() {
  Flowable.just(1)
  .concatMapCompletable(new Function<Integer, CompletableSource>() {
    @Override
    public CompletableSource apply(Integer v) throws Exception {
      throw new TestException();
    }
  })
  .test()
  .assertFailure(TestException.class);
}

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

@Test
public void simple2() {
  final AtomicInteger counter = new AtomicInteger();
  Flowable.range(1, 5)
  .concatMapCompletable(Functions.justFunction(Completable.fromAction(new Action() {
    @Override
    public void run() throws Exception {
      counter.incrementAndGet();
    }
  })))
  .test()
  .assertResult();
  assertEquals(5, counter.get());
}

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

@Test
public void disposed() {
  TestHelper.checkDisposed(
      Flowable.never()
      .concatMapCompletable(
          Functions.justFunction(Completable.complete()))
  );
}

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

@Test
public void simpleLongPrefetch() {
  Flowable.range(1, 1024)
  .concatMapCompletable(Functions.justFunction(Completable.complete()), 32)
  .test()
  .assertResult();
}

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

@Test
public void simple() {
  Flowable.range(1, 5)
  .concatMapCompletable(Functions.justFunction(Completable.complete()))
  .test()
  .assertResult();
}

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

@Test
public void innerError() {
  Flowable.just(1)
  .concatMapCompletable(Functions.justFunction(Completable.error(new TestException())))
  .test()
  .assertFailure(TestException.class);
}

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

@Test
public void mainError() {
  Flowable.<Integer>error(new TestException())
  .concatMapCompletable(Functions.justFunction(Completable.complete()))
  .test()
  .assertFailure(TestException.class);
}

相关文章

Flowable类方法