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

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

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

Subject.onError介绍

暂无

代码示例

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

@Override
  public void run() {
    s.onError(ex);
  }
};

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

@Override
  public void run() {
    s.onError(ex);
  }
};

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

@Override
  public void run() {
    ps2.onError(ex);
  }
};

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

@Override
  public void run() {
    ps2.onError(ex);
  }
};

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

@Override
  public void run() {
    s.onError(ex);
  }
};

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

@Override
  public void run() {
    ps1.onError(ex);
  }
};

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

@Override
  public void run() {
    try {
      Thread.sleep(500);
    } catch (InterruptedException e) {
      // ignore
    }
    o.onError(new TestException());
  }
}.start();

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

@Test(expected = TestException.class)
public void testMostRecentWithException() {
  Subject<String> s = PublishSubject.create();
  Iterator<String> it = mostRecent(s, "default").iterator();
  assertTrue(it.hasNext());
  assertEquals("default", it.next());
  assertEquals("default", it.next());
  s.onError(new TestException());
  assertTrue(it.hasNext());
  it.next();
}

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

return;
actual.onError(t);

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

@Test
public void testOnError() throws Throwable {
  Subject<String> obs = PublishSubject.create();
  Iterator<String> it = next(obs).iterator();
  obs.onError(new TestException());
  try {
    it.hasNext();
    fail("Expected an TestException");
  } catch (TestException e) {
    // successful
  }
  assertErrorAfterObservableFail(it);
}

代码示例来源:origin: redisson/redisson

return;
actual.onError(t);

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

@Test
  public void onErrorNull() {
    Subject<T> p = create();

    try {
      p.onError(null);
      fail("No NullPointerException thrown");
    } catch (NullPointerException ex) {
      assertEquals("onError called with null. Null values are generally not allowed in 2.x operators and sources.", ex.getMessage());
    }

    p.test().assertEmpty().cancel();
  }
}

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

void onError(Throwable e) {
  subject.onError(e);
}

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

@Test
public void normal() {
  Subject<Integer> s = PublishSubject.<Integer>create().toSerialized();
  TestObserver<Integer> to = s.test();
  Observable.range(1, 10).subscribe(s);
  to.assertResult(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  assertFalse(s.hasObservers());
  s.onNext(11);
  List<Throwable> errors = TestHelper.trackPluginErrors();
  try {
    s.onError(new TestException());
    TestHelper.assertUndeliverable(errors, 0, TestException.class);
  } finally {
    RxJavaPlugins.reset();
  }
  s.onComplete();
  Disposable bs = Disposables.empty();
  s.onSubscribe(bs);
  assertTrue(bs.isDisposed());
}

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

@Test
public void sj1ToSj2NullException() {
  rx.subjects.PublishSubject<Integer> ps1 = rx.subjects.PublishSubject.create();
  io.reactivex.subjects.Subject<Integer> sj2 = toV2Subject(ps1);
  io.reactivex.observers.TestObserver<Integer> to = sj2.test();
  sj2.onError(null);
  assertFalse(sj2.hasObservers());
  assertFalse(ps1.hasObservers());
  to.assertFailure(NullPointerException.class);
}

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

@Override
public void onError(Throwable t) {
  upstream.lazySet(DisposableHelper.DISPOSED);
  actual.onError(t);
}

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

@Override
  public void run() {
    try {
      action.accept(subject, d);
    } catch (Throwable ex) {
      Exceptions.throwIfFatal(ex);
      subject.onError(ex);
    }
  }
}));

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

@Test
public void sj1ToSj2Error() {
  rx.subjects.PublishSubject<Integer> ps1 = rx.subjects.PublishSubject.create();
  io.reactivex.subjects.Subject<Integer> sj2 = toV2Subject(ps1);
  io.reactivex.observers.TestObserver<Integer> to = sj2.test();
  assertTrue(sj2.hasObservers());
  assertTrue(ps1.hasObservers());
  assertFalse(sj2.hasComplete());
  assertFalse(sj2.hasThrowable());
  assertNull(sj2.getThrowable());
  sj2.onError(new IOException());
  assertFalse(sj2.hasObservers());
  assertFalse(ps1.hasObservers());
  assertFalse(sj2.hasComplete());
  assertTrue(sj2.hasThrowable());
  assertNotNull(sj2.getThrowable());
  assertTrue(sj2.getThrowable() instanceof IOException);
  to.assertFailure(IOException.class);
}

代码示例来源:origin: io.apptik.rhub/roxy-rxjava2

@Override
public void onError(Throwable e) {
  if (tePolicy.equals(WRAP)) {
    subj.onNext(new Event.ErrorEvent(e));
  } else if (tePolicy.equals(PASS)) {
    subj.onError(e);
  }
}

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

@Test
public void sj1ToSj2Lifecycle() {
  rx.subjects.PublishSubject<Integer> ps1 = rx.subjects.PublishSubject.create();
  io.reactivex.subjects.Subject<Integer> sj2 = toV2Subject(ps1);
  io.reactivex.observers.TestObserver<Integer> to = sj2.test();
  assertTrue(sj2.hasObservers());
  assertTrue(ps1.hasObservers());
  assertFalse(sj2.hasComplete());
  assertFalse(sj2.hasThrowable());
  assertNull(sj2.getThrowable());
  Disposable d1 = Disposables.empty();
  sj2.onSubscribe(d1);
  assertFalse(d1.isDisposed());
  sj2.onNext(1);
  sj2.onNext(2);
  sj2.onComplete();
  sj2.onComplete();
  sj2.onError(new IOException());
  sj2.onNext(3);
  Disposable d2 = Disposables.empty();
  sj2.onSubscribe(d2);
  assertFalse(d1.isDisposed());
  assertTrue(d2.isDisposed());
  assertFalse(sj2.hasObservers());
  assertFalse(ps1.hasObservers());
  assertTrue(sj2.hasComplete());
  assertFalse(sj2.hasThrowable());
  assertNull(sj2.getThrowable());
  to.assertResult(1, 2);
}

相关文章