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

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

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

Flowable.concatEager介绍

[英]Concatenates a sequence of Publishers eagerly into a single stream of values.

Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source Publishers. The operator buffers the values emitted by these Publishers and then drains them in order, each one after the previous one completes. Backpressure: Backpressure is honored towards the downstream and the inner Publishers are expected to support backpressure. Violating this assumption, the operator will signal MissingBackpressureException. Scheduler: This method does not operate by default on a particular Scheduler.
[中]将一系列发布者急切地连接成一个单一的值流。
即时连接意味着一旦订阅者订阅,该操作员就订阅所有源发布者。运算符缓冲这些发布服务器发出的值,然后依次将其排出,在前一个发布服务器完成后再排出。背压:背压朝向下游,预计内部出版商将支持背压。违反此假设,操作员将发出MissingBackpressureException信号。调度程序:默认情况下,此方法不会在特定调度程序上运行。

代码示例

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

@SuppressWarnings("unchecked")
@Test
public void badCapacityHint() throws Exception {
  Flowable<Integer> source = Flowable.just(1);
  try {
    Flowable.concatEager(Arrays.asList(source, source, source), 1, -99);
  } catch (IllegalArgumentException ex) {
    assertEquals("prefetch > 0 required but it was -99", ex.getMessage());
  }
}

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

@Test
public void concatEagerZero() {
  Flowable.concatEager(Collections.<Flowable<Integer>>emptyList())
  .test()
  .assertResult();
}

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

/**
 * Concatenates a sequence of Publishers eagerly into a single stream of values.
 * <p>
 * Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
 * source Publishers. The operator buffers the values emitted by these Publishers and then drains them
 * in order, each one after the previous one completes.
 * <dl>
 *  <dt><b>Backpressure:</b></dt>
 *  <dd>Backpressure is honored towards the downstream and the inner Publishers are
 *  expected to support backpressure. Violating this assumption, the operator will
 *  signal {@code MissingBackpressureException}.</dd>
 *  <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 Publishers that need to be eagerly concatenated
 * @return the new Publisher instance with the specified concatenation behavior
 * @since 2.0
 */
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public static <T> Flowable<T> concatEager(Iterable<? extends Publisher<? extends T>> sources) {
  return concatEager(sources, bufferSize(), bufferSize());
}

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

/**
 * Concatenates a Publisher sequence of Publishers eagerly into a single stream of values.
 * <p>
 * Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
 * emitted source Publishers as they are observed. The operator buffers the values emitted by these
 * Publishers and then drains them in order, each one after the previous one completes.
 * <dl>
 *  <dt><b>Backpressure:</b></dt>
 *  <dd>Backpressure is honored towards the downstream and both the outer and inner Publishers are
 *  expected to support backpressure. Violating this assumption, the operator will
 *  signal {@code MissingBackpressureException}.</dd>
 *  <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 Publishers that need to be eagerly concatenated
 * @return the new Publisher instance with the specified concatenation behavior
 * @since 2.0
 */
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public static <T> Flowable<T> concatEager(Publisher<? extends Publisher<? extends T>> sources) {
  return concatEager(sources, bufferSize(), bufferSize());
}

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

@SuppressWarnings("unchecked")
@Test
public void concatEagerOne() {
  Flowable.concatEager(Arrays.asList(Flowable.just(1)))
  .test()
  .assertResult(1);
}

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

@SuppressWarnings("unchecked")
  @Override
  public Publisher<Long> createPublisher(long elements) {
    return
      Flowable.concatEager(Arrays.asList(
          Flowable.fromIterable(iterate(elements / 2)),
          Flowable.fromIterable(iterate(elements - elements / 2))
        )
      )
    ;
  }
}

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

@SuppressWarnings("unchecked")
@Test
public void concatEagerTwo() {
  Flowable.concatEager(Arrays.asList(Flowable.just(1), Flowable.just(2)))
  .test()
  .assertResult(1, 2);
}

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

@SuppressWarnings("unchecked")
@Test
public void concatEagerIterable() {
  Flowable.concatEager(Arrays.asList(Flowable.just(1), Flowable.just(2)))
  .test()
  .assertResult(1, 2);
}

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

/**
 * Concatenates a Publisher sequence of Publishers eagerly into a single stream of values.
 * <p>
 * Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
 * emitted source Publishers as they are observed. The operator buffers the values emitted by these
 * Publishers and then drains them in order, each one after the previous one completes.
 * <dl>
 *  <dt><b>Backpressure:</b></dt>
 *  <dd>Backpressure is honored towards the downstream and both the outer and inner Publishers are
 *  expected to support backpressure. Violating this assumption, the operator will
 *  signal {@code MissingBackpressureException}.</dd>
 *  <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 Publishers that need to be eagerly concatenated
 * @return the new Publisher instance with the specified concatenation behavior
 * @since 2.0
 */
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public static <T> Flowable<T> concatEager(Publisher<? extends Publisher<? extends T>> sources) {
  return concatEager(sources, bufferSize(), bufferSize());
}

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

/**
 * Concatenates a sequence of Publishers eagerly into a single stream of values.
 * <p>
 * Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
 * source Publishers. The operator buffers the values emitted by these Publishers and then drains them
 * in order, each one after the previous one completes.
 * <dl>
 *  <dt><b>Backpressure:</b></dt>
 *  <dd>Backpressure is honored towards the downstream and the inner Publishers are
 *  expected to support backpressure. Violating this assumption, the operator will
 *  signal {@code MissingBackpressureException}.</dd>
 *  <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 Publishers that need to be eagerly concatenated
 * @return the new Publisher instance with the specified concatenation behavior
 * @since 2.0
 */
@CheckReturnValue
@BackpressureSupport(BackpressureKind.FULL)
@SchedulerSupport(SchedulerSupport.NONE)
public static <T> Flowable<T> concatEager(Iterable<? extends Publisher<? extends T>> sources) {
  return concatEager(sources, bufferSize(), bufferSize());
}

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

@Override
  public Publisher<Long> createPublisher(long elements) {
    return
      Flowable.concatEager(Flowable.just(
          Flowable.fromIterable(iterate(elements / 2)),
          Flowable.fromIterable(iterate(elements - elements / 2))
        )
      )
    ;
  }
}

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

@SuppressWarnings("unchecked")
@Test
public void capacityHint() {
  Flowable<Integer> source = Flowable.just(1);
  TestSubscriber<Integer> ts = TestSubscriber.create();
  Flowable.concatEager(Arrays.asList(source, source, source), 1, 1).subscribe(ts);
  ts.assertValues(1, 1, 1);
  ts.assertNoErrors();
  ts.assertComplete();
}

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

@Test
public void ObservableCapacityHint() {
  Flowable<Integer> source = Flowable.just(1);
  TestSubscriber<Integer> ts = TestSubscriber.create();
  Flowable.concatEager(Flowable.just(source, source, source), 1, 1).subscribe(ts);
  ts.assertValues(1, 1, 1);
  ts.assertNoErrors();
  ts.assertComplete();
}

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

@Test
public void Flowable() {
  Flowable<Integer> source = Flowable.just(1);
  TestSubscriber<Integer> ts = TestSubscriber.create();
  Flowable.concatEager(Flowable.just(source, source, source)).subscribe(ts);
  ts.assertValues(1, 1, 1);
  ts.assertNoErrors();
  ts.assertComplete();
}

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

@Test
public void flowable() {
  Flowable<Integer> source = Flowable.just(1);
  TestSubscriber<Integer> ts = TestSubscriber.create();
  Flowable.concatEager(Flowable.just(source, source, source)).subscribe(ts);
  ts.assertValues(1, 1, 1);
  ts.assertNoErrors();
  ts.assertComplete();
}

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

@Test
public void flowableCapacityHint() {
  Flowable<Integer> source = Flowable.just(1);
  TestSubscriber<Integer> ts = TestSubscriber.create();
  Flowable.concatEager(Flowable.just(source, source, source), 1, 1).subscribe(ts);
  ts.assertValues(1, 1, 1);
  ts.assertNoErrors();
  ts.assertComplete();
}

代码示例来源:origin: com.github.davidmoten/rxjava2-extras

.concatEager(subject.serialize() //
    .toFlowable(BackpressureStrategy.BUFFER), maxConcurrency, 128) //
.doOnRequest(request);

代码示例来源:origin: davidmoten/rxjava2-extras

.concatEager(subject.serialize() //
    .toFlowable(BackpressureStrategy.BUFFER), maxConcurrency, 128) //
.doOnRequest(request);

相关文章

Flowable类方法