io.reactivex.Observable.concatMapSingleDelayError()方法的使用及代码示例

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

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

Observable.concatMapSingleDelayError介绍

[英]Maps the upstream items into SingleSources and subscribes to them one after the other succeeds or fails, emits their success values and delays all errors till both this Observable and all inner SingleSources terminate.

Scheduler: concatMapSingleDelayError does not operate by default on a particular Scheduler.
[中]将上游项映射到单一源中,并一个接一个地订阅它们,发送它们的成功值,并延迟所有错误,直到可观察到的和所有内部单一源终止。
调度程序:默认情况下,concatMapSingleDelayError不会在特定调度程序上运行。

代码示例

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

/**
 * Maps the upstream items into {@link SingleSource}s and subscribes to them one after the
 * other succeeds or fails, emits their success values and delays all errors
 * till both this {@code Observable} and all inner {@code SingleSource}s terminate.
 * <p>
 * <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/concatMap.png" alt="">
 * <dl>
 *  <dt><b>Scheduler:</b></dt>
 *  <dd>{@code concatMapSingleDelayError} does not operate by default on a particular {@link Scheduler}.</dd>
 * </dl>
 * <p>History: 2.1.11 - experimental
 * @param <R> the result type of the inner {@code SingleSource}s
 * @param mapper the function called with the upstream item and should return
 *               a {@code SingleSource} to become the next source to
 *               be subscribed to
 * @return a new Observable instance
 * @see #concatMapSingle(Function)
 * @see #concatMapSingleDelayError(Function, boolean)
 * @since 2.2
 */
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Observable<R> concatMapSingleDelayError(Function<? super T, ? extends SingleSource<? extends R>> mapper) {
  return concatMapSingleDelayError(mapper, true, 2);
}

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

@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Observable<R> concatMapSingleDelayError(Function<? super T, ? extends SingleSource<? extends R>> mapper, boolean tillTheEnd) {
  return concatMapSingleDelayError(mapper, tillTheEnd, 2);

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

@Override
  public Observable<Object> apply(Observable<Object> f)
      throws Exception {
    return f.concatMapSingleDelayError(
        Functions.justFunction(Single.never()));
  }
}

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

/**
 * Maps the upstream items into {@link SingleSource}s and subscribes to them one after the
 * other succeeds or fails, emits their success values and delays all errors
 * till both this {@code Observable} and all inner {@code SingleSource}s terminate.
 * <p>
 * <img width="640" height="305" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/concatMap.png" alt="">
 * <dl>
 *  <dt><b>Scheduler:</b></dt>
 *  <dd>{@code concatMapSingleDelayError} does not operate by default on a particular {@link Scheduler}.</dd>
 * </dl>
 * @param <R> the result type of the inner {@code SingleSource}s
 * @param mapper the function called with the upstream item and should return
 *               a {@code SingleSource} to become the next source to
 *               be subscribed to
 * @return a new Observable instance
 * @since 2.1.11 - experimental
 * @see #concatMapSingle(Function)
 * @see #concatMapSingleDelayError(Function, boolean)
 */
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
@Experimental
public final <R> Observable<R> concatMapSingleDelayError(Function<? super T, ? extends SingleSource<? extends R>> mapper) {
  return concatMapSingleDelayError(mapper, true, 2);
}

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

@Experimental
public final <R> Observable<R> concatMapSingleDelayError(Function<? super T, ? extends SingleSource<? extends R>> mapper, boolean tillTheEnd) {
  return concatMapSingleDelayError(mapper, tillTheEnd, 2);

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

@Test
public void delayAllErrors() {
  Observable.range(1, 5)
  .concatMapSingleDelayError(new Function<Integer, SingleSource<? extends Object>>() {
    @Override
    public SingleSource<? extends Object> apply(Integer v)
        throws Exception {
      return Single.error(new TestException());
    }
  })
  .test()
  .assertFailure(CompositeException.class)
  .assertOf(new Consumer<TestObserver<Object>>() {
    @Override
    public void accept(TestObserver<Object> to) throws Exception {
      CompositeException ce = (CompositeException)to.errors().get(0);
      assertEquals(5, ce.getExceptions().size());
    }
  });
}

相关文章

Observable类方法