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

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

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

Flowable.concat介绍

[英]Concatenates elements of each Publisher provided via an Iterable sequence into a single sequence of elements without interleaving them.

Backpressure: The operator honors backpressure from downstream. The Publishersources are expected to honor backpressure as well. If any of the source Publishers violate this, it may throw an IllegalStateException when the source Publisher completes. Scheduler: concat does not operate by default on a particular Scheduler.
[中]将通过Iterable序列提供的每个发布服务器的元素连接到单个元素序列中,而不交错它们。
背压:操作员接受来自下游的背压。预计出版商资源也将承受背压。如果任何源发布服务器违反此规则,则在源发布服务器完成时,它可能抛出非法状态异常。调度程序:默认情况下,concat不会在特定调度程序上运行。

代码示例

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

@Test(expected = NullPointerException.class)
public void concatIterableNull() {
  Flowable.concat((Iterable<Publisher<Object>>)null);
}

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

@Test(expected = NullPointerException.class)
public void concatFlowableNull() {
  Flowable.concat((Flowable<Flowable<Object>>)null);
}

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

@SuppressWarnings("unchecked")
@Test(expected = NullPointerException.class)
public void concatIterableOneIsNull() {
  Flowable.concat(Arrays.asList(just1, null)).blockingLast();
}

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

@Test(expected = NullPointerException.class)
public void concatIterableIteratorNull() {
  Flowable.concat(new Iterable<Publisher<Object>>() {
    @Override
    public Iterator<Publisher<Object>> iterator() {
      return null;
    }
  }).blockingLast();
}

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

@Override
  public Flowable<Integer> apply(Flowable<Integer> f) {
    return Flowable.concat(f.take(5), f.takeLast(5));
  }
}).subscribe(ts);

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

@Override
  public Flowable<Integer> apply(Flowable<Integer> f) {
    return Flowable.concat(f.take(5), f.takeLast(5));
  }
}).subscribe(ts);

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

@Test
public void testSkipError() {
  Exception e = new Exception();
  Flowable<String> ok = Flowable.just("one");
  Flowable<String> error = Flowable.error(e);
  Flowable<String> skip = Flowable.concat(ok, error).skip(100);
  Subscriber<String> subscriber = TestHelper.mockSubscriber();
  skip.subscribe(subscriber);
  verify(subscriber, never()).onNext(any(String.class));
  verify(subscriber, times(1)).onError(e);
  verify(subscriber, never()).onComplete();
}

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

@Test
public void testConcat() {
  Subscriber<String> subscriber = TestHelper.mockSubscriber();
  final String[] o = { "1", "3", "5", "7" };
  final String[] e = { "2", "4", "6" };
  final Flowable<String> odds = Flowable.fromArray(o);
  final Flowable<String> even = Flowable.fromArray(e);
  Flowable<String> concat = Flowable.concat(odds, even);
  concat.subscribe(subscriber);
  verify(subscriber, times(7)).onNext(anyString());
}

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

@Test
public void concat3() {
  Flowable<Integer> source = Flowable.just(1);
  Flowable.concat(source, source, source)
  .test()
  .assertResult(1, 1, 1);
}

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

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

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

@Test
public void testWithError3() {
  Single<Boolean> single = Flowable.sequenceEqual(
      Flowable.concat(Flowable.just("one"),
          Flowable.<String> error(new TestException())),
      Flowable.concat(Flowable.just("one"),
          Flowable.<String> error(new TestException())));
  verifyError(single);
}

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

@Test
public void testWithError3Flowable() {
  Flowable<Boolean> flowable = Flowable.sequenceEqual(
      Flowable.concat(Flowable.just("one"),
          Flowable.<String> error(new TestException())),
      Flowable.concat(Flowable.just("one"),
          Flowable.<String> error(new TestException()))).toFlowable();
  verifyError(flowable);
}

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

@Test
public void workerNotDisposedPrematurelySyncInNormalOut() {
  DisposeTrackingScheduler s = new DisposeTrackingScheduler();
  Flowable.concat(
      Flowable.just(1).observeOn(s),
      Flowable.just(2)
  )
  .test()
  .assertResult(1, 2);
  assertEquals(1, s.disposedCount.get());
}

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

@Test
public void workerNotDisposedPrematurelySyncInNormalOutConditional() {
  DisposeTrackingScheduler s = new DisposeTrackingScheduler();
  Flowable.concat(
      Flowable.just(1).observeOn(s).filter(Functions.alwaysTrue()),
      Flowable.just(2)
  )
  .test()
  .assertResult(1, 2);
  assertEquals(1, s.disposedCount.get());
}

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

@Test
public void testWithError2() {
  Single<Boolean> single = Flowable.sequenceEqual(
      Flowable.just("one", "two", "three"),
      Flowable.concat(Flowable.just("one"),
          Flowable.<String> error(new TestException())));
  verifyError(single);
}

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

@Test
public void testWithError1() {
  Single<Boolean> single = Flowable.sequenceEqual(
      Flowable.concat(Flowable.just("one"),
          Flowable.<String> error(new TestException())),
      Flowable.just("one", "two", "three"));
  verifyError(single);
}

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

@Test
public void workerNotDisposedPrematurelyNormalInNormalOutConditional() {
  DisposeTrackingScheduler s = new DisposeTrackingScheduler();
  Flowable.concat(
      Flowable.just(1).hide().observeOn(s).filter(Functions.alwaysTrue()),
      Flowable.just(2)
  )
  .test()
  .assertResult(1, 2);
  assertEquals(1, s.disposedCount.get());
}

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

@Test
public void testWithError2Flowable() {
  Flowable<Boolean> flowable = Flowable.sequenceEqual(
      Flowable.just("one", "two", "three"),
      Flowable.concat(Flowable.just("one"),
          Flowable.<String> error(new TestException()))).toFlowable();
  verifyError(flowable);
}

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

@Test
public void testWithError1Flowable() {
  Flowable<Boolean> flowable = Flowable.sequenceEqual(
      Flowable.concat(Flowable.just("one"),
          Flowable.<String> error(new TestException())),
      Flowable.just("one", "two", "three")).toFlowable();
  verifyError(flowable);
}

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

@Test
public void testError2() {
  Flowable<Integer> source = Flowable.concat(Flowable.just(0),
      Flowable.<Integer> error(new TestException("Forced failure")));
  Flowable<Integer> m = source.groupBy(identity, dbl).flatMap(FLATTEN_INTEGER);
  TestSubscriber<Object> ts = new TestSubscriber<Object>();
  m.subscribe(ts);
  ts.awaitTerminalEvent();
  assertEquals(1, ts.errorCount());
  ts.assertValueCount(1);
}

相关文章

Flowable类方法