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

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

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

Observable.concatMapEagerDelayError介绍

[英]Maps a sequence of values into ObservableSources and concatenates these ObservableSources eagerly into a single ObservableSource.

Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

Scheduler: This method does not operate by default on a particular Scheduler.
[中]将一系列值映射到可观测资源中,并将这些可观测资源急切地连接到单个可观测资源中。
即时连接意味着一旦订户订阅,该操作符订阅所有源可观测资源。运算符缓冲这些可观察资源发出的值,然后依次将其耗尽,每一个都在前一个完成之后。
调度器:默认情况下,该方法不会在特定的调度器上运行。

代码示例

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

/**
 * Maps a sequence of values into ObservableSources and concatenates these ObservableSources eagerly into a single
 * ObservableSource.
 * <p>
 * Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
 * source ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in
 * order, each one after the previous one completes.
 * <p>
 * <img width="640" height="390" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/concatMapEagerDelayError.o.png" alt="">
 * <dl>
 *  <dt><b>Scheduler:</b></dt>
 *  <dd>This method does not operate by default on a particular {@link Scheduler}.</dd>
 * </dl>
 * @param <R> the value type
 * @param mapper the function that maps a sequence of values into a sequence of ObservableSources that will be
 *               eagerly concatenated
 * @param tillTheEnd
 *            if true, all errors from the outer and inner ObservableSource sources are delayed until the end,
 *            if false, an error from the main source is signalled when the current ObservableSource source terminates
 * @return the new ObservableSource instance with the specified concatenation behavior
 * @since 2.0
 */
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Observable<R> concatMapEagerDelayError(Function<? super T, ? extends ObservableSource<? extends R>> mapper,
    boolean tillTheEnd) {
  return concatMapEagerDelayError(mapper, Integer.MAX_VALUE, bufferSize(), tillTheEnd);
}

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

/**
 * Concatenates a sequence of ObservableSources eagerly into a single stream of values.
 * <p>
 * Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
 * source ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them
 * in order, each one after the previous one completes.
 * <p>
 * <img width="640" height="380" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/concatEager.png" alt="">
 * <dl>
 *  <dt><b>Scheduler:</b></dt>
 *  <dd>This method does not operate by default on a particular {@link Scheduler}.</dd>
 * </dl>
 * @param <T> the value type
 * @param sources a sequence of ObservableSources that need to be eagerly concatenated
 * @param maxConcurrency the maximum number of concurrently running inner ObservableSources; Integer.MAX_VALUE
 *                       is interpreted as all inner ObservableSources can be active at the same time
 * @param prefetch the number of elements to prefetch from each inner ObservableSource source
 * @return the new ObservableSource instance with the specified concatenation behavior
 * @since 2.0
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public static <T> Observable<T> concatEager(Iterable<? extends ObservableSource<? extends T>> sources, int maxConcurrency, int prefetch) {
  return fromIterable(sources).concatMapEagerDelayError((Function)Functions.identity(), maxConcurrency, prefetch, false);
}

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

/**
 * Concatenates an array of ObservableSources eagerly into a single stream of values.
 * <p>
 * <img width="640" height="495" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/concatArrayEager.nn.png" alt="">
 * <p>
 * Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
 * source ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them
 * in order, each one after the previous one completes.
 * <dl>
 *  <dt><b>Scheduler:</b></dt>
 *  <dd>This method does not operate by default on a particular {@link Scheduler}.</dd>
 * </dl>
 * @param <T> the value type
 * @param sources an array of ObservableSources that need to be eagerly concatenated
 * @param maxConcurrency the maximum number of concurrent subscriptions at a time, Integer.MAX_VALUE
 *                       is interpreted as indication to subscribe to all sources at once
 * @param prefetch the number of elements to prefetch from each ObservableSource source
 * @return the new ObservableSource instance with the specified concatenation behavior
 * @since 2.0
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public static <T> Observable<T> concatArrayEager(int maxConcurrency, int prefetch, ObservableSource<? extends T>... sources) {
  return fromArray(sources).concatMapEagerDelayError((Function)Functions.identity(), maxConcurrency, prefetch, false);
}

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

/**
 * Concatenates an array of {@link ObservableSource}s eagerly into a single stream of values
 * and delaying any errors until all sources terminate.
 * <p>
 * <img width="640" height="460" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/concatArrayEagerDelayError.nn.png" alt="">
 * <p>
 * Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
 * source {@code ObservableSource}s. The operator buffers the values emitted by these {@code ObservableSource}s
 * and then drains them in order, each one after the previous one completes.
 * <dl>
 *  <dt><b>Scheduler:</b></dt>
 *  <dd>This method does not operate by default on a particular {@link Scheduler}.</dd>
 * </dl>
 * @param <T> the value type
 * @param sources an array of {@code ObservableSource}s that need to be eagerly concatenated
 * @param maxConcurrency the maximum number of concurrent subscriptions at a time, Integer.MAX_VALUE
 *                       is interpreted as indication to subscribe to all sources at once
 * @param prefetch the number of elements to prefetch from each {@code ObservableSource} source
 * @return the new Observable instance with the specified concatenation behavior
 * @since 2.2.1 - experimental
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public static <T> Observable<T> concatArrayEagerDelayError(int maxConcurrency, int prefetch, ObservableSource<? extends T>... sources) {
  return fromArray(sources).concatMapEagerDelayError((Function)Functions.identity(), maxConcurrency, prefetch, true);
}

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

/**
 * Maps a sequence of values into ObservableSources and concatenates these ObservableSources eagerly into a single
 * ObservableSource.
 * <p>
 * Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
 * source ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in
 * order, each one after the previous one completes.
 * <p>
 * <img width="640" height="390" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/concatMapEagerDelayError.o.png" alt="">
 * <dl>
 *  <dt><b>Scheduler:</b></dt>
 *  <dd>This method does not operate by default on a particular {@link Scheduler}.</dd>
 * </dl>
 * @param <R> the value type
 * @param mapper the function that maps a sequence of values into a sequence of ObservableSources that will be
 *               eagerly concatenated
 * @param tillTheEnd
 *            if true, all errors from the outer and inner ObservableSource sources are delayed until the end,
 *            if false, an error from the main source is signalled when the current ObservableSource source terminates
 * @return the new ObservableSource instance with the specified concatenation behavior
 * @since 2.0
 */
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public final <R> Observable<R> concatMapEagerDelayError(Function<? super T, ? extends ObservableSource<? extends R>> mapper,
    boolean tillTheEnd) {
  return concatMapEagerDelayError(mapper, Integer.MAX_VALUE, bufferSize(), tillTheEnd);
}

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

/**
 * Concatenates a sequence of ObservableSources eagerly into a single stream of values.
 * <p>
 * Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
 * source ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them
 * in order, each one after the previous one completes.
 * <dl>
 *  <dt><b>Scheduler:</b></dt>
 *  <dd>This method does not operate by default on a particular {@link Scheduler}.</dd>
 * </dl>
 * @param <T> the value type
 * @param sources a sequence of ObservableSources that need to be eagerly concatenated
 * @param maxConcurrency the maximum number of concurrent subscriptions at a time, Integer.MAX_VALUE
 *                       is interpreted as indication to subscribe to all sources at once
 * @param prefetch the number of elements to prefetch from each ObservableSource source
 * @return the new ObservableSource instance with the specified concatenation behavior
 * @since 2.0
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public static <T> Observable<T> concatArrayEager(int maxConcurrency, int prefetch, ObservableSource<? extends T>... sources) {
  return fromArray(sources).concatMapEagerDelayError((Function)Functions.identity(), maxConcurrency, prefetch, false);
}

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

@Test
public void normalDelayEnd() {
  Observable.range(1, 5)
  .concatMapEagerDelayError(new Function<Integer, ObservableSource<Integer>>() {
    @Override
    public ObservableSource<Integer> apply(Integer t) {
      return Observable.range(t, 2);
    }
  }, true)
  .test()
  .assertResult(1, 2, 2, 3, 3, 4, 4, 5, 5, 6);
}

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

@Test
public void normalDelayBoundary() {
  Observable.range(1, 5)
  .concatMapEagerDelayError(new Function<Integer, ObservableSource<Integer>>() {
    @Override
    public ObservableSource<Integer> apply(Integer t) {
      return Observable.range(t, 2);
    }
  }, false)
  .test()
  .assertResult(1, 2, 2, 3, 3, 4, 4, 5, 5, 6);
}

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

/**
 * Concatenates a sequence of ObservableSources eagerly into a single stream of values.
 * <p>
 * Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
 * source ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them
 * in order, each one after the previous one completes.
 * <p>
 * <img width="640" height="380" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/concatEager.png" alt="">
 * <dl>
 *  <dt><b>Scheduler:</b></dt>
 *  <dd>This method does not operate by default on a particular {@link Scheduler}.</dd>
 * </dl>
 * @param <T> the value type
 * @param sources a sequence of ObservableSources that need to be eagerly concatenated
 * @param maxConcurrency the maximum number of concurrently running inner ObservableSources; Integer.MAX_VALUE
 *                       is interpreted as all inner ObservableSources can be active at the same time
 * @param prefetch the number of elements to prefetch from each inner ObservableSource source
 * @return the new ObservableSource instance with the specified concatenation behavior
 * @since 2.0
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@CheckReturnValue
@SchedulerSupport(SchedulerSupport.NONE)
public static <T> Observable<T> concatEager(Iterable<? extends ObservableSource<? extends T>> sources, int maxConcurrency, int prefetch) {
  ObjectHelper.requireNonNull(maxConcurrency, "maxConcurrency is null");
  ObjectHelper.requireNonNull(prefetch, "prefetch is null");
  return fromIterable(sources).concatMapEagerDelayError((Function)Functions.identity(), maxConcurrency, prefetch, false);
}

相关文章

Observable类方法