io.reactivex.subjects.Subject.hasThrowable()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(12.8k)|赞(0)|评价(0)|浏览(169)

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

Subject.hasThrowable介绍

[英]Returns true if the subject has reached a terminal state through an error event.

The method is thread-safe.
[中]如果主题通过错误事件达到终端状态,则返回true。
该方法是线程安全的。

代码示例

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

@Override
public boolean hasThrowable() {
  return actual.hasThrowable();
}

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

@Test
public void testPublishSubjectValueEmpty() {
  PublishSubject<Integer> async = PublishSubject.create();
  async.onComplete();
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertTrue(serial.hasComplete());
  assertFalse(serial.hasThrowable());
  assertNull(serial.getThrowable());
}

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

@Test
public void testPublishSubjectValueRelay() {
  PublishSubject<Integer> async = PublishSubject.create();
  async.onNext(1);
  async.onComplete();
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertTrue(serial.hasComplete());
  assertFalse(serial.hasThrowable());
  assertNull(serial.getThrowable());
}

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

@Test
public void testPublishSubjectValueError() {
  PublishSubject<Integer> async = PublishSubject.create();
  TestException te = new TestException();
  async.onError(te);
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertFalse(serial.hasComplete());
  assertTrue(serial.hasThrowable());
  assertSame(te, serial.getThrowable());
}

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

@Test
public void testReplaySubjectValueRelayEmptyIncomplete() {
  ReplaySubject<Integer> async = ReplaySubject.create();
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertFalse(serial.hasComplete());
  assertFalse(serial.hasThrowable());
  assertNull(serial.getThrowable());
  assertNull(async.getValue());
  assertFalse(async.hasValue());
  assertArrayEquals(new Object[] { }, async.getValues());
  assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
  assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
  assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

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

@Test
public void testReplaySubjectValueRelayBoundedEmptyIncomplete() {
  ReplaySubject<Integer> async = ReplaySubject.createWithSize(1);
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertFalse(serial.hasComplete());
  assertFalse(serial.hasThrowable());
  assertNull(serial.getThrowable());
  assertNull(async.getValue());
  assertFalse(async.hasValue());
  assertArrayEquals(new Object[] { }, async.getValues());
  assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
  assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
  assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

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

@SuppressWarnings("deprecation")
@Test
public void testBehaviorSubjectIncompleteEmpty() {
  BehaviorSubject<Integer> async = BehaviorSubject.create();
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertFalse(serial.hasComplete());
  assertFalse(serial.hasThrowable());
  assertNull(serial.getThrowable());
  assertNull(async.getValue());
  assertFalse(async.hasValue());
  assertArrayEquals(new Object[] { }, async.getValues());
  assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
  assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
  assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

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

@SuppressWarnings("deprecation")
@Test
public void testAsyncSubjectValueEmpty() {
  AsyncSubject<Integer> async = AsyncSubject.create();
  async.onComplete();
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertTrue(serial.hasComplete());
  assertFalse(serial.hasThrowable());
  assertNull(serial.getThrowable());
  assertNull(async.getValue());
  assertFalse(async.hasValue());
  assertArrayEquals(new Object[] { }, async.getValues());
  assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
  assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
  assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

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

@Test
public void testReplaySubjectBoundedEmpty() {
  ReplaySubject<Integer> async = ReplaySubject.createWithSize(1);
  async.onComplete();
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertTrue(serial.hasComplete());
  assertFalse(serial.hasThrowable());
  assertNull(serial.getThrowable());
  assertNull(async.getValue());
  assertFalse(async.hasValue());
  assertArrayEquals(new Object[] { }, async.getValues());
  assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
  assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
  assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

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

@Test
public void testReplaySubjectValueRelayIncomplete() {
  ReplaySubject<Integer> async = ReplaySubject.create();
  async.onNext(1);
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertFalse(serial.hasComplete());
  assertFalse(serial.hasThrowable());
  assertNull(serial.getThrowable());
  assertEquals((Integer)1, async.getValue());
  assertTrue(async.hasValue());
  assertArrayEquals(new Object[] { 1 }, async.getValues());
  assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
  assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
  assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
}

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

@Test
public void testReplaySubjectEmpty() {
  ReplaySubject<Integer> async = ReplaySubject.create();
  async.onComplete();
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertTrue(serial.hasComplete());
  assertFalse(serial.hasThrowable());
  assertNull(serial.getThrowable());
  assertNull(async.getValue());
  assertFalse(async.hasValue());
  assertArrayEquals(new Object[] { }, async.getValues());
  assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
  assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
  assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

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

@SuppressWarnings("deprecation")
@Test
public void testBehaviorSubjectEmpty() {
  BehaviorSubject<Integer> async = BehaviorSubject.create();
  async.onComplete();
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertTrue(serial.hasComplete());
  assertFalse(serial.hasThrowable());
  assertNull(serial.getThrowable());
  assertNull(async.getValue());
  assertFalse(async.hasValue());
  assertArrayEquals(new Object[] { }, async.getValues());
  assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
  assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
  assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

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

@SuppressWarnings("deprecation")
@Test
public void testBehaviorSubjectValueRelayIncomplete() {
  BehaviorSubject<Integer> async = BehaviorSubject.create();
  async.onNext(1);
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertFalse(serial.hasComplete());
  assertFalse(serial.hasThrowable());
  assertNull(serial.getThrowable());
  assertEquals((Integer)1, async.getValue());
  assertTrue(async.hasValue());
  assertArrayEquals(new Object[] { 1 }, async.getValues());
  assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
  assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
  assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
}

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

@Test
public void testReplaySubjectError() {
  ReplaySubject<Integer> async = ReplaySubject.create();
  TestException te = new TestException();
  async.onError(te);
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertFalse(serial.hasComplete());
  assertTrue(serial.hasThrowable());
  assertSame(te, serial.getThrowable());
  assertNull(async.getValue());
  assertFalse(async.hasValue());
  assertArrayEquals(new Object[] { }, async.getValues());
  assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
  assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
  assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

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

@Test
public void testReplaySubjectBoundedError() {
  ReplaySubject<Integer> async = ReplaySubject.createWithSize(1);
  TestException te = new TestException();
  async.onError(te);
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertFalse(serial.hasComplete());
  assertTrue(serial.hasThrowable());
  assertSame(te, serial.getThrowable());
  assertNull(async.getValue());
  assertFalse(async.hasValue());
  assertArrayEquals(new Object[] { }, async.getValues());
  assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
  assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
  assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

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

@Test
public void testReplaySubjectValueRelay() {
  ReplaySubject<Integer> async = ReplaySubject.create();
  async.onNext(1);
  async.onComplete();
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertTrue(serial.hasComplete());
  assertFalse(serial.hasThrowable());
  assertNull(serial.getThrowable());
  assertEquals((Integer)1, async.getValue());
  assertTrue(async.hasValue());
  assertArrayEquals(new Object[] { 1 }, async.getValues());
  assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
  assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
  assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
}

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

@Test
public void testReplaySubjectValueRelayBoundedIncomplete() {
  ReplaySubject<Integer> async = ReplaySubject.createWithSize(1);
  async.onNext(0);
  async.onNext(1);
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertFalse(serial.hasComplete());
  assertFalse(serial.hasThrowable());
  assertNull(serial.getThrowable());
  assertEquals((Integer)1, async.getValue());
  assertTrue(async.hasValue());
  assertArrayEquals(new Object[] { 1 }, async.getValues());
  assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
  assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
  assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
}

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

@SuppressWarnings("deprecation")
@Test
public void testBehaviorSubjectError() {
  BehaviorSubject<Integer> async = BehaviorSubject.create();
  TestException te = new TestException();
  async.onError(te);
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertFalse(serial.hasComplete());
  assertTrue(serial.hasThrowable());
  assertSame(te, serial.getThrowable());
  assertNull(async.getValue());
  assertFalse(async.hasValue());
  assertArrayEquals(new Object[] { }, async.getValues());
  assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
  assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
  assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

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

@SuppressWarnings("deprecation")
@Test
public void testAsyncSubjectValueError() {
  AsyncSubject<Integer> async = AsyncSubject.create();
  TestException te = new TestException();
  async.onError(te);
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertFalse(serial.hasComplete());
  assertTrue(serial.hasThrowable());
  assertSame(te, serial.getThrowable());
  assertNull(async.getValue());
  assertFalse(async.hasValue());
  assertArrayEquals(new Object[] { }, async.getValues());
  assertArrayEquals(new Integer[] { }, async.getValues(new Integer[0]));
  assertArrayEquals(new Integer[] { null }, async.getValues(new Integer[] { 0 }));
  assertArrayEquals(new Integer[] { null, 0 }, async.getValues(new Integer[] { 0, 0 }));
}

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

@Test
public void testReplaySubjectValueRelayBounded() {
  ReplaySubject<Integer> async = ReplaySubject.createWithSize(1);
  async.onNext(0);
  async.onNext(1);
  async.onComplete();
  Subject<Integer> serial = async.toSerialized();
  assertFalse(serial.hasObservers());
  assertTrue(serial.hasComplete());
  assertFalse(serial.hasThrowable());
  assertNull(serial.getThrowable());
  assertEquals((Integer)1, async.getValue());
  assertTrue(async.hasValue());
  assertArrayEquals(new Object[] { 1 }, async.getValues());
  assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[0]));
  assertArrayEquals(new Integer[] { 1 }, async.getValues(new Integer[] { 0 }));
  assertArrayEquals(new Integer[] { 1, null }, async.getValues(new Integer[] { 0, 0 }));
}

相关文章