本文整理汇总了Java中rx.subjects.PublishSubject.onError方法的典型用法代码示例。如果您正苦于以下问题:Java PublishSubject.onError方法的具体用法?Java PublishSubject.onError怎么用?Java PublishSubject.onError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rx.subjects.PublishSubject
的用法示例。
在下文中一共展示了PublishSubject.onError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: error
import rx.subjects.PublishSubject; //导入方法依赖的package包/类
@Test
public void error() {
TestScheduler scheduler = new TestScheduler();
PublishSubject<Integer> subject = PublishSubject.create();
RecordingObserver<Integer> o = new RecordingObserver<>();
subject
.lift(new OperatorNormalize<Integer>(1, TimeUnit.SECONDS, scheduler))
.subscribe(o);
// First emits immediately
subject.onNext(0);
o.takeNext();
subject.onNext(1);
subject.onError(new RuntimeException("Blah"));
o.assertNoMoreEvents();
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
o.takeNext();
assertThat(o.takeError()).isInstanceOf(RuntimeException.class);
}
示例2: testEmitsErrors
import rx.subjects.PublishSubject; //导入方法依赖的package包/类
@Test
public void testEmitsErrors() {
final PublishSubject<Integer> source = PublishSubject.create();
final Observable<Throwable> result = source
.materialize()
.compose(Transformers.errors());
final TestSubscriber<Throwable> resultTest = new TestSubscriber<>();
result.subscribe(resultTest);
source.onNext(1);
resultTest.assertNoValues();
// Only emit when an error is thrown.
source.onError(new Throwable());
resultTest.assertValueCount(1);
}
示例3: testErrorsDoNotEmit
import rx.subjects.PublishSubject; //导入方法依赖的package包/类
@Test
public void testErrorsDoNotEmit() {
final PublishSubject<Integer> source = PublishSubject.create();
final Observable<Integer> result = source
.materialize()
.compose(Transformers.values());
final TestSubscriber<Integer> resultTest = new TestSubscriber<>();
result.subscribe(resultTest);
//
source.onNext(1);
resultTest.assertValues(1);
// An error in the source stream should not emit values.
source.onError(new Throwable());
resultTest.assertValues(1);
}
示例4: refreshError
import rx.subjects.PublishSubject; //导入方法依赖的package包/类
@Test
public void refreshError() throws Exception {
PublishSubject<Reddit> subject = PublishSubject.create();
Mockito.doReturn(subject.asObservable().toList())
.when(mRepository)
.getReddits(Mockito.anyString());
mViewModel.refresh();
Mockito.verify(mRepository).getReddits("test");
Assert.assertThat(mViewModel.errorText.get(), IsNull.nullValue());
Assert.assertThat(mViewModel.isLoading.get(), Is.is(true));
subject.onError(new Exception("error text"));
Assert.assertThat(mViewModel.isLoading.get(), Is.is(false));
Assert.assertThat(mViewModel.errorText.get(), IsEqual.equalTo("error text"));
}
示例5: testErrorDoesNotEmitACompletedNotification
import rx.subjects.PublishSubject; //导入方法依赖的package包/类
@Test
public void testErrorDoesNotEmitACompletedNotification() {
final PublishSubject<Integer> source = PublishSubject.create();
final Observable<Void> result = source
.materialize()
.compose(Transformers.completed());
final TestSubscriber<Void> resultTest = new TestSubscriber<>();
result.subscribe(resultTest);
source.onError(new Throwable());
resultTest.assertValueCount(0);
}
示例6: onError
import rx.subjects.PublishSubject; //导入方法依赖的package包/类
void onError(int requestCode, ActivityNotFoundException exception) {
PublishSubject<ActivityResult> subject = results.remove(requestCode);
subject.onError(exception);
}