本文整理了Java中io.reactivex.Single.toFlowable()
方法的一些代码示例,展示了Single.toFlowable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Single.toFlowable()
方法的具体详情如下:
包路径:io.reactivex.Single
类名称:Single
方法名:toFlowable
[英]Converts this Single into a Flowable.
Backpressure: The returned Flowable honors the backpressure of the downstream consumer. Scheduler: toFlowable does not operate by default on a particular Scheduler.
[中]将此单体转换为可流动的。
背压:返回的可流动性尊重下游消费者的背压。Scheduler:toFlowable默认情况下不会在特定的计划程序上运行。
代码示例来源:origin: ReactiveX/RxJava
@Override
public Flowable<Object> apply(Flowable<Object> f) throws Exception {
return f.last(2).toFlowable();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public Flowable<List<Object>> apply(Flowable<Object> f)
throws Exception {
return f.toList().toFlowable();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public Object apply(Flowable<Object> f) throws Exception {
return f.singleOrError().toFlowable();
}
}, false, 1, 1, 1);
代码示例来源:origin: ReactiveX/RxJava
@Override
public Publisher<Boolean> createPublisher(final long elements) {
return
Flowable.range(1, 1000).all(new Predicate<Integer>() {
@Override
public boolean test(Integer e) throws Exception {
return e < 800;
}
}).toFlowable()
;
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public Publisher<Boolean> apply(Flowable<Object> f) throws Exception {
return f.any(Functions.alwaysTrue()).toFlowable();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Test
@Ignore("null values are not allowed")
public void testContainsWithNullFlowable() {
Flowable<Boolean> flowable = Flowable.just("a", "b", null).contains(null).toFlowable();
Subscriber<Object> subscriber = TestHelper.mockSubscriber();
flowable.subscribe(subscriber);
verify(subscriber, times(1)).onNext(true);
verify(subscriber, never()).onNext(false);
verify(subscriber, never()).onError(any(Throwable.class));
verify(subscriber, times(1)).onComplete();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testFirstOrDefaultFlowable() {
Flowable<Integer> flowable = Flowable.just(1, 2, 3)
.first(4).toFlowable();
Subscriber<Integer> subscriber = TestHelper.mockSubscriber();
flowable.subscribe(subscriber);
InOrder inOrder = inOrder(subscriber);
inOrder.verify(subscriber, times(1)).onNext(1);
inOrder.verify(subscriber, times(1)).onComplete();
inOrder.verifyNoMoreInteractions();
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public Publisher<Boolean> createPublisher(final long elements) {
return
Flowable.sequenceEqual(
Flowable.range(1, 1000),
Flowable.range(1, 1001))
.toFlowable()
;
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testSingleOrDefaultWithTooManyElementsFlowable() {
Flowable<Integer> flowable = Flowable.just(1, 2).single(3).toFlowable();
Subscriber<Integer> subscriber = TestHelper.mockSubscriber();
flowable.subscribe(subscriber);
InOrder inOrder = inOrder(subscriber);
inOrder.verify(subscriber, times(1)).onError(
isA(IllegalArgumentException.class));
inOrder.verifyNoMoreInteractions();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void test1Flowable() {
Flowable<Boolean> flowable = Flowable.sequenceEqual(
Flowable.just("one", "two", "three"),
Flowable.just("one", "two", "three")).toFlowable();
verifyResult(flowable, true);
}
代码示例来源: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 testWithEqualityErrorFlowable() {
Flowable<Boolean> flowable = Flowable.sequenceEqual(
Flowable.just("one"), Flowable.just("one"),
new BiPredicate<String, String>() {
@Override
public boolean test(String t1, String t2) {
throw new TestException();
}
}).toFlowable();
verifyError(flowable);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void singleOrError() {
Flowable.empty()
.singleOrError()
.toFlowable()
.test()
.assertFailure(NoSuchElementException.class);
}
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void firstOrErrorOneElementFlowable() {
Flowable.just(1)
.firstOrError()
.toFlowable()
.test()
.assertNoErrors()
.assertValue(1);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testJustTwoEmissionsObservableThrowsError() {
TestSubscriber<String> subscriber = TestSubscriber.create();
Single<String> single = Flowable.just("First", "Second").single("");
single.toFlowable().subscribe(subscriber);
subscriber.assertError(IllegalArgumentException.class);
}
代码示例来源: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 prefetchFlowable() {
Flowable.sequenceEqual(Flowable.range(1, 20), Flowable.range(1, 20), 2)
.toFlowable()
.test()
.assertResult(true);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void dispose() {
TestHelper.checkDisposed(Flowable.just(1).count());
TestHelper.checkDisposed(Flowable.just(1).count().toFlowable());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void andThenSingleNever() {
TestSubscriber<String> ts = new TestSubscriber<String>(0);
Completable.never().andThen(Single.just("foo")).toFlowable().subscribe(ts);
ts.request(1);
ts.assertNoValues();
ts.assertNotTerminated();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void cancelAsFlowable() {
PublishProcessor<Integer> pp = PublishProcessor.create();
TestSubscriber<Integer> ts = pp.singleOrError().toFlowable().test();
assertTrue(pp.hasSubscribers());
ts.assertEmpty();
ts.cancel();
assertFalse(pp.hasSubscribers());
}
内容来源于网络,如有侵权,请联系作者删除!