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

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

本文整理了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

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

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

  1. @Override
  2. public Completable apply(Flowable<Object> f)
  3. throws Exception {
  4. return f.concatMapCompletable(
  5. Functions.justFunction(Completable.complete()));
  6. }
  7. }

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

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

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

  1. @Test
  2. public void mapperCrash() {
  3. Flowable.just(1)
  4. .concatMapCompletable(new Function<Integer, CompletableSource>() {
  5. @Override
  6. public CompletableSource apply(Integer v) throws Exception {
  7. throw new TestException();
  8. }
  9. })
  10. .test()
  11. .assertFailure(TestException.class);
  12. }

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

  1. @Test
  2. public void simple2() {
  3. final AtomicInteger counter = new AtomicInteger();
  4. Flowable.range(1, 5)
  5. .concatMapCompletable(Functions.justFunction(Completable.fromAction(new Action() {
  6. @Override
  7. public void run() throws Exception {
  8. counter.incrementAndGet();
  9. }
  10. })))
  11. .test()
  12. .assertResult();
  13. assertEquals(5, counter.get());
  14. }

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

  1. @Test
  2. public void disposed() {
  3. TestHelper.checkDisposed(
  4. Flowable.never()
  5. .concatMapCompletable(
  6. Functions.justFunction(Completable.complete()))
  7. );
  8. }

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

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

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

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

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

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

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

  1. @Test
  2. public void mainError() {
  3. Flowable.<Integer>error(new TestException())
  4. .concatMapCompletable(Functions.justFunction(Completable.complete()))
  5. .test()
  6. .assertFailure(TestException.class);
  7. }

相关文章

Flowable类方法