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

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

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

Flowable.skipWhile介绍

[英]Returns a Flowable that skips all items emitted by the source Publisher as long as a specified condition holds true, but emits all further source items as soon as the condition becomes false.

Backpressure: The operator doesn't interfere with backpressure which is determined by the source Publisher's backpressure behavior. Scheduler: skipWhile does not operate by default on a particular Scheduler.
[中]返回一个可流动项,只要指定的条件为true,它将跳过源发布服务器发出的所有项,但一旦条件为false,它将立即发出所有其他源项。
背压:操作员不会干扰由源发布者的背压行为确定的背压。Scheduler:skipWhile默认情况下不会在特定的计划程序上运行。

代码示例

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

@Override
  public Flowable<Object> apply(Flowable<Object> f) throws Exception {
    return f.skipWhile(Functions.alwaysFalse());
  }
});

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

@Override
public Flowable<Integer> apply(Flowable<Integer> xs) {
  return xs.takeUntil(xs.skipWhile(new Predicate<Integer>() {
    @Override
    public boolean test(Integer i) {
      return i <= 3;
    }
  }));
}

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

@Test(expected = NullPointerException.class)
public void skipWhileNull() {
  just1.skipWhile(null);
}

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

@Test
public void testSkipWithIndex() {
  Flowable<Integer> src = Flowable.just(1, 2, 3, 4, 5);
  src.skipWhile(INDEX_LESS_THAN_THREE).subscribe(w);
  InOrder inOrder = inOrder(w);
  inOrder.verify(w, times(1)).onNext(4);
  inOrder.verify(w, times(1)).onNext(5);
  inOrder.verify(w, times(1)).onComplete();
  inOrder.verify(w, never()).onError(any(Throwable.class));
}

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

@Override
  public Publisher<Integer> createPublisher(long elements) {
    return
        Flowable.range(0, (int)elements).skipWhile(Functions.alwaysFalse())
    ;
  }
}

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

@Test
public void testSkipSome() {
  Flowable<Integer> src = Flowable.just(1, 2, 3, 4, 5, 3, 1, 5);
  src.skipWhile(LESS_THAN_FIVE).subscribe(w);
  InOrder inOrder = inOrder(w);
  inOrder.verify(w, times(1)).onNext(5);
  inOrder.verify(w, times(1)).onNext(3);
  inOrder.verify(w, times(1)).onNext(1);
  inOrder.verify(w, times(1)).onNext(5);
  inOrder.verify(w, times(1)).onComplete();
  inOrder.verify(w, never()).onError(any(Throwable.class));
}

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

@Test
public void testSkipError() {
  Flowable<Integer> src = Flowable.just(1, 2, 42, 5, 3, 1);
  src.skipWhile(LESS_THAN_FIVE).subscribe(w);
  InOrder inOrder = inOrder(w);
  inOrder.verify(w, never()).onNext(anyInt());
  inOrder.verify(w, never()).onComplete();
  inOrder.verify(w, times(1)).onError(any(RuntimeException.class));
}

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

@Test
public void testSkipEmpty() {
  Flowable<Integer> src = Flowable.empty();
  src.skipWhile(LESS_THAN_FIVE).subscribe(w);
  verify(w, never()).onNext(anyInt());
  verify(w, never()).onError(any(Throwable.class));
  verify(w, times(1)).onComplete();
}

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

@Test
public void testSkipNothing() {
  Flowable<Integer> src = Flowable.just(5, 3, 1);
  src.skipWhile(LESS_THAN_FIVE).subscribe(w);
  InOrder inOrder = inOrder(w);
  inOrder.verify(w, times(1)).onNext(5);
  inOrder.verify(w, times(1)).onNext(3);
  inOrder.verify(w, times(1)).onNext(1);
  inOrder.verify(w, times(1)).onComplete();
  inOrder.verify(w, never()).onError(any(Throwable.class));
}

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

@Test
public void testSkipEverything() {
  Flowable<Integer> src = Flowable.just(1, 2, 3, 4, 3, 2, 1);
  src.skipWhile(LESS_THAN_FIVE).subscribe(w);
  verify(w, never()).onNext(anyInt());
  verify(w, never()).onError(any(Throwable.class));
  verify(w, times(1)).onComplete();
}

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

@Test
public void testSkipManySubscribers() {
  Flowable<Integer> src = Flowable.range(1, 10).skipWhile(LESS_THAN_FIVE);
  int n = 5;
  for (int i = 0; i < n; i++) {
    Subscriber<Object> subscriber = TestHelper.mockSubscriber();
    InOrder inOrder = inOrder(subscriber);
    src.subscribe(subscriber);
    for (int j = 5; j < 10; j++) {
      inOrder.verify(subscriber).onNext(j);
    }
    inOrder.verify(subscriber).onComplete();
    verify(subscriber, never()).onError(any(Throwable.class));
  }
}

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

@Test
  public void error() {
    Flowable.error(new TestException())
    .skipWhile(Functions.alwaysFalse())
    .test()
    .assertFailure(TestException.class);
  }
}

代码示例来源:origin: io.smallrye.reactive/smallrye-reactive-streams-operators

@Override
  public Flowable<I> apply(Flowable<I> source) {
    return source.skipWhile(predicate::test);
  }
}

相关文章

Flowable类方法