本文整理了Java中rx.subjects.Subject.hasObservers()
方法的一些代码示例,展示了Subject.hasObservers()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Subject.hasObservers()
方法的具体详情如下:
包路径:rx.subjects.Subject
类名称:Subject
方法名:hasObservers
暂无
代码示例来源:origin: cn-ljb/rxjava_for_android
/**是否含有观察者*/
public boolean hasObservers() {
return _bus.hasObservers();
}
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Override
public boolean hasObservers() {
return source.hasObservers();
}
代码示例来源:origin: THEONE10211024/RxJavaSamples
public boolean hasObservers() {
return _bus.hasObservers();
}
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Override
public boolean hasSubscribers() {
return source.hasObservers();
}
代码示例来源:origin: laotan7237/EasyReader
/**
* 判断是否有订阅者
*/
public boolean hasObservers() {
return _bus.hasObservers();
}
代码示例来源:origin: com.netflix.eureka/eureka2-core
@Override
public boolean hasObservers() {
return delegate.hasObservers();
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj2ToSj1Error() {
io.reactivex.subjects.PublishSubject<Integer> ps2 = io.reactivex.subjects.PublishSubject.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(ps2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test();
assertTrue(sj1.hasObservers());
assertTrue(ps2.hasObservers());
sj1.onError(new IOException());
assertFalse(sj1.hasObservers());
assertFalse(ps2.hasObservers());
to.assertFailure(IOException.class);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj2ToSj1Normal() {
io.reactivex.subjects.PublishSubject<Integer> ps2 = io.reactivex.subjects.PublishSubject.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(ps2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test();
assertTrue(sj1.hasObservers());
assertTrue(ps2.hasObservers());
sj1.onNext(1);
sj1.onNext(2);
sj1.onCompleted();
assertFalse(sj1.hasObservers());
assertFalse(ps2.hasObservers());
to.assertResult(1, 2);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj1ToFp2Lifecycle() {
rx.subjects.Subject<Integer, Integer> sj1 = rx.subjects.PublishSubject.create();
io.reactivex.processors.FlowableProcessor<Integer> pp2 = toV2Processor(sj1);
io.reactivex.subscribers.TestSubscriber<Integer> to = pp2.test(0L);
assertTrue(sj1.hasObservers());
assertTrue(pp2.hasSubscribers());
pp2.onNext(1);
pp2.onError(new IOException());
assertFalse(sj1.hasObservers());
assertFalse(pp2.hasSubscribers());
assertFalse(pp2.hasComplete());
assertTrue(pp2.hasThrowable());
assertNotNull(pp2.getThrowable());
to.assertFailure(rx.exceptions.MissingBackpressureException.class);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj2ToSj1Lifecycle() {
io.reactivex.subjects.PublishSubject<Integer> pp2 = io.reactivex.subjects.PublishSubject.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(pp2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test(0L);
assertTrue(sj1.hasObservers());
assertTrue(pp2.hasObservers());
sj1.onNext(1);
sj1.onError(new IOException());
assertFalse(sj1.hasObservers());
assertFalse(pp2.hasObservers());
assertFalse(pp2.hasComplete());
assertTrue(pp2.hasThrowable());
assertNotNull(pp2.getThrowable());
to.assertFailure(rx.exceptions.MissingBackpressureException.class);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj1ToFp2NullValue() {
rx.subjects.Subject<Integer, Integer> sj1 = rx.subjects.PublishSubject.create();
io.reactivex.processors.FlowableProcessor<Integer> pp2 = toV2Processor(sj1);
io.reactivex.subscribers.TestSubscriber<Integer> to = pp2.test();
pp2.onNext(null);
assertFalse(pp2.hasSubscribers());
assertFalse(sj1.hasObservers());
to.assertFailure(NullPointerException.class);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj1ToFp2NullException() {
rx.subjects.Subject<Integer, Integer> sj1 = rx.subjects.PublishSubject.create();
io.reactivex.processors.FlowableProcessor<Integer> pp2 = toV2Processor(sj1);
io.reactivex.subscribers.TestSubscriber<Integer> to = pp2.test();
pp2.onError(null);
assertFalse(pp2.hasSubscribers());
assertFalse(sj1.hasObservers());
to.assertFailure(NullPointerException.class);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void fp2ToSj1Error() {
io.reactivex.processors.FlowableProcessor<Integer> pp2 = io.reactivex.processors.PublishProcessor.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(pp2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test();
assertTrue(sj1.hasObservers());
assertTrue(pp2.hasSubscribers());
sj1.onError(new IOException());
assertFalse(sj1.hasObservers());
assertFalse(pp2.hasSubscribers());
assertFalse(pp2.hasComplete());
assertTrue(pp2.hasThrowable());
assertNotNull(pp2.getThrowable());
assertTrue(pp2.getThrowable() instanceof IOException);
to.assertFailure(IOException.class);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj1ToFp2Error() {
rx.subjects.Subject<Integer, Integer> sj1 = rx.subjects.PublishSubject.create();
io.reactivex.processors.FlowableProcessor<Integer> pp2 = toV2Processor(sj1);
io.reactivex.subscribers.TestSubscriber<Integer> to = pp2.test();
assertTrue(sj1.hasObservers());
assertTrue(pp2.hasSubscribers());
pp2.onError(new IOException());
assertFalse(sj1.hasObservers());
assertFalse(pp2.hasSubscribers());
assertFalse(pp2.hasComplete());
assertTrue(pp2.hasThrowable());
assertNotNull(pp2.getThrowable());
assertTrue(pp2.getThrowable() instanceof IOException);
to.assertFailure(IOException.class);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj2ToSj1Backpressured() {
io.reactivex.subjects.PublishSubject<Integer> pp2 = io.reactivex.subjects.PublishSubject.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(pp2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test(0L);
assertTrue(sj1.hasObservers());
assertTrue(pp2.hasObservers());
sj1.onNext(1);
assertFalse(sj1.hasObservers());
assertFalse(pp2.hasObservers());
assertFalse(pp2.hasComplete());
assertFalse(pp2.hasThrowable());
assertNull(pp2.getThrowable());
to.assertFailure(rx.exceptions.MissingBackpressureException.class);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void fp2ToSj1Normal() {
io.reactivex.processors.FlowableProcessor<Integer> pp2 = io.reactivex.processors.PublishProcessor.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(pp2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test();
assertTrue(sj1.hasObservers());
assertTrue(pp2.hasSubscribers());
sj1.onNext(1);
sj1.onNext(2);
sj1.onCompleted();
assertFalse(sj1.hasObservers());
assertFalse(pp2.hasSubscribers());
assertTrue(pp2.hasComplete());
assertFalse(pp2.hasThrowable());
assertNull(pp2.getThrowable());
to.assertResult(1, 2);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj1ToFp2Normal() {
rx.subjects.Subject<Integer, Integer> sj1 = rx.subjects.PublishSubject.create();
io.reactivex.processors.FlowableProcessor<Integer> pp2 = toV2Processor(sj1);
io.reactivex.subscribers.TestSubscriber<Integer> to = pp2.test();
assertTrue(sj1.hasObservers());
assertTrue(pp2.hasSubscribers());
pp2.onNext(1);
pp2.onNext(2);
pp2.onComplete();
assertFalse(sj1.hasObservers());
assertFalse(pp2.hasSubscribers());
assertTrue(pp2.hasComplete());
assertFalse(pp2.hasThrowable());
assertNull(pp2.getThrowable());
to.assertResult(1, 2);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj1ToFp2Lifecycle2() {
rx.subjects.Subject<Integer, Integer> sj1 = rx.subjects.PublishSubject.create();
io.reactivex.processors.FlowableProcessor<Integer> pp2 = toV2Processor(sj1);
io.reactivex.subscribers.TestSubscriber<Integer> to = pp2.test();
assertTrue(pp2.hasSubscribers());
assertTrue(sj1.hasObservers());
assertFalse(pp2.hasComplete());
assertFalse(pp2.hasThrowable());
assertNull(pp2.getThrowable());
BooleanSubscription d1 = new BooleanSubscription();
pp2.onSubscribe(d1);
assertFalse(d1.isCancelled());
pp2.onNext(1);
pp2.onNext(2);
pp2.onComplete();
pp2.onComplete();
pp2.onError(new IOException());
pp2.onNext(3);
BooleanSubscription d2 = new BooleanSubscription();
pp2.onSubscribe(d2);
assertFalse(d1.isCancelled());
assertTrue(d2.isCancelled());
assertFalse(pp2.hasSubscribers());
assertFalse(sj1.hasObservers());
assertTrue(pp2.hasComplete());
assertFalse(pp2.hasThrowable());
assertNull(pp2.getThrowable());
to.assertResult(1, 2);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void fp2ToSj1Backpressured() {
io.reactivex.processors.FlowableProcessor<Integer> pp2 = io.reactivex.processors.ReplayProcessor.create();
rx.subjects.Subject<Integer, Integer> sj1 = toV1Subject(pp2);
rx.observers.AssertableSubscriber<Integer> to = sj1.test(0L);
assertTrue(sj1.hasObservers());
assertTrue(pp2.hasSubscribers());
sj1.onNext(1);
sj1.onNext(2);
sj1.onNext(3);
sj1.onNext(4);
to.assertNoValues().assertNoErrors().assertNotCompleted();
to.requestMore(1).assertValue(1).assertNoErrors().assertNotCompleted();
to.requestMore(2).assertValues(1, 2, 3).assertNoErrors().assertNotCompleted();
sj1.onCompleted();
to.assertValues(1, 2, 3).assertNoErrors().assertNotCompleted();
assertFalse(sj1.hasObservers());
assertFalse(pp2.hasSubscribers());
assertTrue(pp2.hasComplete());
assertFalse(pp2.hasThrowable());
assertNull(pp2.getThrowable());
to
.requestMore(1)
.assertResult(1, 2, 3, 4);
}
代码示例来源:origin: akarnokd/RxJava2Interop
@Test
public void sj1ToFp2Backpressured() {
rx.subjects.Subject<Integer, Integer> sj1 = rx.subjects.ReplaySubject.create();
io.reactivex.processors.FlowableProcessor<Integer> pp2 = toV2Processor(sj1);
io.reactivex.subscribers.TestSubscriber<Integer> to = pp2.test(0L);
assertTrue(sj1.hasObservers());
assertTrue(pp2.hasSubscribers());
pp2.onNext(1);
pp2.onNext(2);
pp2.onNext(3);
pp2.onNext(4);
to.assertNoValues().assertNoErrors().assertNotComplete();
to.requestMore(1).assertValue(1).assertNoErrors().assertNotComplete();
to.requestMore(2).assertValues(1, 2, 3).assertNoErrors().assertNotComplete();
pp2.onComplete();
to.assertValues(1, 2, 3).assertNoErrors().assertNotComplete();
assertFalse(sj1.hasObservers());
assertFalse(pp2.hasSubscribers());
assertTrue(pp2.hasComplete());
assertFalse(pp2.hasThrowable());
assertNull(pp2.getThrowable());
to
.requestMore(1)
.assertResult(1, 2, 3, 4);
}
内容来源于网络,如有侵权,请联系作者删除!