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

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

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

Flowable.to介绍

[英]Calls the specified converter function during assembly time and returns its resulting value.

This allows fluent conversion to any other type. Backpressure: The backpressure behavior depends on what happens in the converter function. Scheduler: to does not operate by default on a particular Scheduler.
[中]在汇编期间调用指定的转换器函数并返回其结果值。
这允许流畅地转换为任何其他类型。背压:背压行为取决于转换器功能中发生的情况。调度程序:默认情况下,不在特定调度程序上运行。

代码示例

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

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

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

.to(new Function<Flowable<Integer>, ConcurrentLinkedQueue<Integer>>() {
  @Override
  public ConcurrentLinkedQueue<Integer> apply(Flowable<Integer> onSubscribe) {

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

@Test
public void testExtend() {
  final TestSubscriber<Object> subscriber = new TestSubscriber<Object>();
  final Object value = new Object();
  Object returned = Flowable.just(value).to(new Function<Flowable<Object>, Object>() {
    @Override
    public Object apply(Flowable<Object> onSubscribe) {
        onSubscribe.subscribe(subscriber);
        subscriber.assertNoErrors();
        subscriber.assertComplete();
        subscriber.assertValue(value);
        return subscriber.values().get(0);
      }
  });
  assertSame(returned, value);
}

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

@Test
public void syncIterable() {
  Flowable.fromIterable(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
  .to(SubscriberFusion.<Integer>test(Long.MAX_VALUE, QueueFuseable.ANY, false))
  .assertOf(SubscriberFusion.<Integer>assertFusionMode(QueueFuseable.SYNC))
  .assertValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
  .assertNoErrors()
  .assertComplete();
}

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

@Test
  public void syncIterableHidden() {
    Flowable.fromIterable(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
    .hide()
    .to(SubscriberFusion.<Integer>test(Long.MAX_VALUE, QueueFuseable.ANY, false))
    .assertOf(SubscriberFusion.<Integer>assertNotFuseable())
    .assertOf(SubscriberFusion.<Integer>assertFusionMode(QueueFuseable.NONE))
    .assertValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    .assertNoErrors()
    .assertComplete();
  }
}

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

@Test
public void syncArray() {
  Flowable.fromArray(new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 })
  .to(SubscriberFusion.<Integer>test(Long.MAX_VALUE, QueueFuseable.ANY, false))
  .assertOf(SubscriberFusion.<Integer>assertFusionMode(QueueFuseable.SYNC))
  .assertValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
  .assertNoErrors()
  .assertComplete();
}

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

@Test
public void syncRange() {
  Flowable.range(1, 10)
  .to(SubscriberFusion.<Integer>test(Long.MAX_VALUE, QueueFuseable.ANY, false))
  .assertOf(SubscriberFusion.<Integer>assertFusionMode(QueueFuseable.SYNC))
  .assertValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
  .assertNoErrors()
  .assertComplete();
}

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

@Test
public void directComparerFused() {
  Flowable.fromArray(1, 2, 2, 3, 2, 4, 1, 1, 2)
  .distinctUntilChanged(new BiPredicate<Integer, Integer>() {
    @Override
    public boolean test(Integer a, Integer b) {
      return a.equals(b);
    }
  })
  .to(SubscriberFusion.<Integer>test(Long.MAX_VALUE, QueueFuseable.ANY, false))
  .assertOf(SubscriberFusion.<Integer>assertFuseable())
  .assertOf(SubscriberFusion.<Integer>assertFusionMode(QueueFuseable.SYNC))
  .assertResult(1, 2, 3, 2, 4, 1, 2);
}

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

.to(new ConvertToCylonDetector<Object>())
.beep(new Predicate<Object>() {
  @Override

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

@Test
public void syncArrayHidden() {
  Flowable.fromArray(new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 })
  .hide()
  .to(SubscriberFusion.<Integer>test(Long.MAX_VALUE, QueueFuseable.ANY, false))
  .assertOf(SubscriberFusion.<Integer>assertNotFuseable())
  .assertOf(SubscriberFusion.<Integer>assertFusionMode(QueueFuseable.NONE))
  .assertValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
  .assertNoErrors()
  .assertComplete();
}

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

@Test
public void syncRangeHidden() {
  Flowable.range(1, 10).hide()
  .to(SubscriberFusion.<Integer>test(Long.MAX_VALUE, QueueFuseable.ANY, false))
  .assertOf(SubscriberFusion.<Integer>assertNotFuseable())
  .assertOf(SubscriberFusion.<Integer>assertFusionMode(QueueFuseable.NONE))
  .assertValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
  .assertNoErrors()
  .assertComplete();
}

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

@Test
public void directComparerConditionalFused() {
  Flowable.fromArray(1, 2, 2, 3, 2, 4, 1, 1, 2)
  .distinctUntilChanged(new BiPredicate<Integer, Integer>() {
    @Override
    public boolean test(Integer a, Integer b) {
      return a.equals(b);
    }
  })
  .filter(new Predicate<Integer>() {
    @Override
    public boolean test(Integer v) {
      return true;
    }
  })
  .to(SubscriberFusion.<Integer>test(Long.MAX_VALUE, QueueFuseable.ANY, false))
  .assertOf(SubscriberFusion.<Integer>assertFuseable())
  .assertOf(SubscriberFusion.<Integer>assertFusionMode(QueueFuseable.SYNC))
  .assertResult(1, 2, 3, 2, 4, 1, 2);
}

代码示例来源:origin: akarnokd/RxJava2Jdk8Interop

@Test
public void firstElement() {
  Assert.assertEquals((Integer)1, Flowable.range(1, 5)
  .to(FlowableInterop.firstElement()).get());
}

代码示例来源:origin: akarnokd/RxJava2Jdk8Interop

@Test
public void lastElement() {
  Assert.assertEquals((Integer)5, Flowable.range(1, 5)
  .to(FlowableInterop.lastElement()).get());
}

代码示例来源:origin: akarnokd/RxJava2Jdk8Interop

@Test
public void last() {
  TestHelper.assertFuture(5, Flowable.range(1, 5)
      .to(FlowableInterop.last())
  );
}

代码示例来源:origin: akarnokd/RxJava2Jdk8Interop

@Test
public void first() {
  TestHelper.assertFuture(1, Flowable.range(1, 5)
      .to(FlowableInterop.first())
  );
}

代码示例来源:origin: akarnokd/RxJava2Jdk8Interop

@Test(expected = NoSuchElementException.class)
public void firstEmpty() {
  TestHelper.assertFuture(null, Flowable.empty()
      .to(FlowableInterop.first())
  );
}

代码示例来源:origin: akarnokd/RxJava2Jdk8Interop

@Test(expected = NoSuchElementException.class)
public void lastEmpty() {
  TestHelper.assertFuture(null, Flowable.empty()
      .to(FlowableInterop.last())
  );
}

代码示例来源:origin: akarnokd/RxJava2Jdk8Interop

@Test(expected = NoSuchElementException.class)
public void singleEmpty() {
  TestHelper.assertFuture(null, Flowable.empty()
      .to(FlowableInterop.single())
  );
}

代码示例来源:origin: akarnokd/RxJava2Jdk8Interop

@Test
public void single() {
  TestHelper.assertFuture(1, Flowable.just(1)
      .to(FlowableInterop.single())
  );
}

相关文章

Flowable类方法