本文整理了Java中io.reactivex.Flowable.all()
方法的一些代码示例,展示了Flowable.all()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flowable.all()
方法的具体详情如下:
包路径:io.reactivex.Flowable
类名称:Flowable
方法名:all
[英]Returns a Single that emits a Boolean that indicates whether all of the items emitted by the source Publisher satisfy a condition.
Backpressure: The operator honors backpressure from downstream and consumes the source Publisher in an unbounded manner (i.e., without applying backpressure). Scheduler: all does not operate by default on a particular Scheduler.
[中]返回发出布尔值的单个值,该布尔值指示源发布服务器发出的所有项是否满足某个条件。
背压:操作员接受来自下游的背压,并以无限制的方式(即不施加背压)消耗源发布服务器。调度程序:默认情况下,在特定的调度程序上不运行all。
代码示例来源:origin: ReactiveX/RxJava
@Override
public Single<Boolean> apply(Flowable<Object> f) throws Exception {
return f.all(Functions.alwaysTrue());
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public Object apply(Flowable<Integer> f) throws Exception {
return f.all(Functions.alwaysTrue());
}
}, false, 1, 1, true);
代码示例来源:origin: ReactiveX/RxJava
@Test(expected = NullPointerException.class)
public void allPredicateNull() {
just1.all(null);
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public Object apply(Flowable<Integer> f) throws Exception {
return f.all(Functions.alwaysTrue()).toFlowable();
}
}, false, 1, 1, true);
代码示例来源: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.all(Functions.alwaysTrue()).toFlowable();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testError() {
Throwable error = new Throwable();
Flowable<String> obs = Flowable.error(error);
SingleObserver<Boolean> observer = TestHelper.mockSingleObserver();
obs.all(new Predicate<String>() {
@Override
public boolean test(String s) {
return s.length() == 3;
}
})
.subscribe(observer);
verify(observer).onSubscribe((Disposable)any());
verify(observer).onError(error);
verifyNoMoreInteractions(observer);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testEmpty() {
Flowable<String> obs = Flowable.empty();
SingleObserver<Boolean> observer = TestHelper.mockSingleObserver();
obs.all(new Predicate<String>() {
@Override
public boolean test(String s) {
return s.length() == 3;
}
})
.subscribe(observer);
verify(observer).onSubscribe((Disposable)any());
verify(observer).onSuccess(true);
verifyNoMoreInteractions(observer);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testAll() {
Flowable<String> obs = Flowable.just("one", "two", "six");
SingleObserver<Boolean> observer = TestHelper.mockSingleObserver();
obs.all(new Predicate<String>() {
@Override
public boolean test(String s) {
return s.length() == 3;
}
})
.subscribe(observer);
verify(observer).onSubscribe((Disposable)any());
verify(observer).onSuccess(true);
verifyNoMoreInteractions(observer);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testNotAll() {
Flowable<String> obs = Flowable.just("one", "two", "three", "six");
SingleObserver<Boolean> observer = TestHelper.mockSingleObserver();
obs.all(new Predicate<String>() {
@Override
public boolean test(String s) {
return s.length() == 3;
}
})
.subscribe(observer);
verify(observer).onSubscribe((Disposable)any());
verify(observer).onSuccess(false);
verifyNoMoreInteractions(observer);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testAllFlowable() {
Flowable<String> obs = Flowable.just("one", "two", "six");
Subscriber<Boolean> subscriber = TestHelper.mockSubscriber();
obs.all(new Predicate<String>() {
@Override
public boolean test(String s) {
return s.length() == 3;
}
})
.toFlowable()
.subscribe(subscriber);
verify(subscriber).onSubscribe((Subscription)any());
verify(subscriber).onNext(true);
verify(subscriber).onComplete();
verifyNoMoreInteractions(subscriber);
}
代码示例来源:origin: ReactiveX/RxJava
@Test(timeout = 5000)
public void testIssue1935NoUnsubscribeDownstream() {
Flowable<Integer> source = Flowable.just(1)
.all(new Predicate<Integer>() {
@Override
public boolean test(Integer t1) {
return false;
}
})
.flatMapPublisher(new Function<Boolean, Publisher<Integer>>() {
@Override
public Publisher<Integer> apply(Boolean t1) {
return Flowable.just(2).delay(500, TimeUnit.MILLISECONDS);
}
});
assertEquals((Object)2, source.blockingFirst());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testFollowingFirst() {
Flowable<Integer> f = Flowable.fromArray(1, 3, 5, 6);
Single<Boolean> allOdd = f.all(new Predicate<Integer>() {
@Override
public boolean test(Integer i) {
return i % 2 == 1;
}
});
assertFalse(allOdd.blockingGet());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void dispose() {
TestHelper.checkDisposed(Flowable.just(1).all(Functions.alwaysTrue()).toFlowable());
TestHelper.checkDisposed(Flowable.just(1).all(Functions.alwaysTrue()));
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testPredicateThrowsExceptionAndValueInCauseMessage() {
TestObserver<Boolean> to = new TestObserver<Boolean>();
final IllegalArgumentException ex = new IllegalArgumentException();
Flowable.just("Boo!").all(new Predicate<String>() {
@Override
public boolean test(String v) {
throw ex;
}
})
.subscribe(to);
to.assertTerminated();
to.assertNoValues();
to.assertNotComplete();
to.assertError(ex);
// FIXME need to decide about adding the value that probably caused the crash in some way
// assertTrue(ex.getCause().getMessage().contains("Boo!"));
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testFollowingFirstFlowable() {
Flowable<Integer> f = Flowable.fromArray(1, 3, 5, 6);
Flowable<Boolean> allOdd = f.all(new Predicate<Integer>() {
@Override
public boolean test(Integer i) {
return i % 2 == 1;
}
})
.toFlowable()
;
assertFalse(allOdd.blockingFirst());
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testBackpressureIfOneRequestedOneShouldBeDelivered() {
TestObserver<Boolean> to = new TestObserver<Boolean>();
Flowable.empty().all(new Predicate<Object>() {
@Override
public boolean test(Object t) {
return false;
}
}).subscribe(to);
to.assertTerminated();
to.assertNoErrors();
to.assertComplete();
to.assertValue(true);
}
代码示例来源:origin: ReactiveX/RxJava
@Test
@Ignore("No backpressure in Single")
public void testBackpressureIfNoneRequestedNoneShouldBeDelivered() {
TestObserver<Boolean> to = new TestObserver<Boolean>();
Flowable.empty().all(new Predicate<Object>() {
@Override
public boolean test(Object t1) {
return false;
}
}).subscribe(to);
to.assertNoValues();
to.assertNoErrors();
to.assertNotComplete();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testBackpressureIfNoneRequestedNoneShouldBeDeliveredFlowable() {
TestSubscriber<Boolean> ts = new TestSubscriber<Boolean>(0L);
Flowable.empty().all(new Predicate<Object>() {
@Override
public boolean test(Object t1) {
return false;
}
})
.toFlowable()
.subscribe(ts);
ts.assertNoValues();
ts.assertNoErrors();
ts.assertNotComplete();
}
代码示例来源:origin: ReactiveX/RxJava
@Test
public void testBackpressureIfOneRequestedOneShouldBeDeliveredFlowable() {
TestSubscriber<Boolean> ts = new TestSubscriber<Boolean>(1L);
Flowable.empty().all(new Predicate<Object>() {
@Override
public boolean test(Object t) {
return false;
}
})
.toFlowable()
.subscribe(ts);
ts.assertTerminated();
ts.assertNoErrors();
ts.assertComplete();
ts.assertValue(true);
}
内容来源于网络,如有侵权,请联系作者删除!