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

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

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

Flowable.empty介绍

[英]Returns a Flowable that emits no items to the Subscriber and immediately invokes its Subscriber#onComplete method.

Backpressure: This source doesn't produce any elements and effectively ignores downstream backpressure. Scheduler: empty does not operate by default on a particular Scheduler.
[中]返回不向订阅服务器发送任何项并立即调用其订阅服务器#onComplete方法的Flowable。
背压:该源不产生任何元素,有效地忽略了下游背压。Scheduler:empty默认情况下不会在特定计划程序上运行。

代码示例

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

@Override
  public Flowable<Object> apply(Flowable<? extends Throwable> t1) {
    return Flowable.empty();
  }
}).subscribe(ts);

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

@Test
public void testDistinctUntilChangedOfNone() {
  Flowable<String> src = Flowable.empty();
  src.distinctUntilChanged().subscribe(w);
  verify(w, never()).onNext(anyString());
  verify(w, never()).onError(any(Throwable.class));
  verify(w, times(1)).onComplete();
}

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

@Test
public void testSkipEmptyStream() {
  Flowable<String> w = Flowable.empty();
  Flowable<String> skip = w.skip(1);
  Subscriber<String> subscriber = TestHelper.mockSubscriber();
  skip.subscribe(subscriber);
  verify(subscriber, never()).onNext(any(String.class));
  verify(subscriber, never()).onError(any(Throwable.class));
  verify(subscriber, times(1)).onComplete();
}

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

@Test
public void testFirstOfNoneFlowable() {
  Flowable<Integer> flowable = Flowable.empty();
  flowable.firstElement().toFlowable().subscribe(w);
  verify(w, never()).onNext(anyInt());
  verify(w).onComplete();
  verify(w, never()).onError(any(Throwable.class));
}

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

@Test
public void testSingleOrDefaultWithEmpty() {
  Single<Integer> single = Flowable.<Integer> empty()
      .single(1);
  SingleObserver<Integer> observer = TestHelper.mockSingleObserver();
  single.subscribe(observer);
  InOrder inOrder = inOrder(observer);
  inOrder.verify(observer, times(1)).onSuccess(1);
  inOrder.verifyNoMoreInteractions();
}

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

@Test
public void testCompletePassThru() {
  Flowable<Integer> flowable = Flowable.empty();
  Flowable<Integer> dematerialize = flowable.dematerialize();
  Subscriber<Integer> subscriber = TestHelper.mockSubscriber();
  TestSubscriber<Integer> ts = new TestSubscriber<Integer>(subscriber);
  dematerialize.subscribe(ts);
  System.out.println(ts.errors());
  verify(subscriber, never()).onError(any(Throwable.class));
  verify(subscriber, times(1)).onComplete();
  verify(subscriber, times(0)).onNext(any(Integer.class));
}

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

@SuppressWarnings("unchecked")
@Test
public void testInnerEmpty() {
  Flowable.concatArrayEager(Flowable.empty(), Flowable.empty()).subscribe(ts);
  ts.assertNoValues();
  ts.assertNoErrors();
  ts.assertComplete();
}

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

@Test(timeout = 5000)
public void mergeDelayErrorObservableEmpty() {
  Completable c = Completable.mergeDelayError(Flowable.<Completable>empty());
  c.blockingAwait();
}

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

@SuppressWarnings("unchecked")
@Test
public void ambArrayEmpty() {
  assertSame(Flowable.empty(), Flowable.ambArray());
}

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

@Test
public void blockingFirstDefault() {
  assertEquals(1, Flowable.<Integer>empty()
      .subscribeOn(Schedulers.computation()).blockingFirst(1).intValue());
}

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

@Test
public void fromPublisherEmpty() {
  Completable.fromPublisher(Flowable.empty())
    .test()
    .assertResult();
}

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

@Test
public void scanEmptyBackpressured() {
  Flowable.<Integer>empty()
  .scan(0, SUM)
  .test(1)
  .assertResult(0);
}

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

@Test
public void timedEmptyOther() {
  Flowable.empty()
  .timeout(1, TimeUnit.DAYS, Flowable.just(1))
  .test()
  .assertResult();
}

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

@Test
public void testWithEmpty2Flowable() {
  Flowable<Boolean> flowable = Flowable.sequenceEqual(
      Flowable.just("one", "two", "three"),
      Flowable.<String> empty()).toFlowable();
  verifyResult(flowable, false);
}

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

@Test
public void singleOrErrorNoElement() {
  Flowable.empty()
    .singleOrError()
    .test()
    .assertNoValues()
    .assertError(NoSuchElementException.class);
}

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

@Test
  public void singleOrError() {
    Flowable.empty()
    .singleOrError()
    .toFlowable()
    .test()
    .assertFailure(NoSuchElementException.class);
  }
}

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

@Test
public void normalEmpty() {
  Flowable.empty()
  .doFinally(this)
  .test()
  .assertResult();
  assertEquals(1, calls);
}

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

@Test
public void testEmptyObservable() {
  TestSubscriber<String> subscriber = TestSubscriber.create();
  Single<String> single = Flowable.<String>empty().single("");
  single.toFlowable().subscribe(subscriber);
  subscriber.assertResult("");
}

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

@Test
public void empty() {
  Flowable.empty()
  .timeout(Functions.justFunction(Flowable.never()))
  .test()
  .assertResult();
}

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

@SuppressWarnings("unchecked")
@Test
public void emptyConditionalBackpressured() {
  TestSubscriber<Object> ts = new TestSubscriber<Object>(0L);
  Flowable.empty()
  .parallel(1)
  .runOn(ImmediateThinScheduler.INSTANCE)
  .filter(Functions.alwaysTrue())
  .subscribe(new Subscriber[] { ts });
  ts
  .assertResult();
}

相关文章

Flowable类方法