当前位置: 首页>>代码示例>>Java>>正文


Java PublishSubject.onError方法代码示例

本文整理汇总了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);
}
 
开发者ID:hzsweers,项目名称:RxNormalize,代码行数:22,代码来源:OperatorNormalizeTest.java

示例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);
}
 
开发者ID:kickstarter,项目名称:android-oss,代码行数:18,代码来源:ErrorsTransformerTest.java

示例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);
}
 
开发者ID:kickstarter,项目名称:android-oss,代码行数:20,代码来源:ValuesTransformerTest.java

示例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"));
}
 
开发者ID:DanielSerdyukov,项目名称:droidcon2016,代码行数:15,代码来源:RedditListViewModelTest.java

示例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);
}
 
开发者ID:kickstarter,项目名称:android-oss,代码行数:14,代码来源:CompletedTransformerTest.java

示例6: onError

import rx.subjects.PublishSubject; //导入方法依赖的package包/类
void onError(int requestCode, ActivityNotFoundException exception) {
    PublishSubject<ActivityResult> subject = results.remove(requestCode);
    subject.onError(exception);
}
 
开发者ID:NateWickstrom,项目名称:RxActivityResult,代码行数:5,代码来源:RxActivityResult.java


注:本文中的rx.subjects.PublishSubject.onError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。