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


Java Subject.onCompleted方法代码示例

本文整理汇总了Java中rx.subjects.Subject.onCompleted方法的典型用法代码示例。如果您正苦于以下问题:Java Subject.onCompleted方法的具体用法?Java Subject.onCompleted怎么用?Java Subject.onCompleted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rx.subjects.Subject的用法示例。


在下文中一共展示了Subject.onCompleted方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1:

import rx.subjects.Subject; //导入方法依赖的package包/类
@Test
public void should_only_emits_the_last_item_and_call_onComplete_without_throwing_exception_when_AsyncSubject_without_error() {
  Subject<String, String> asyncSubjectSubject = AsyncSubject.<String>create();

  asyncSubjectSubject.subscribe(mTestSubscriber);
  asyncSubjectSubject.onNext("One");
  asyncSubjectSubject.onNext("Two");
  asyncSubjectSubject.onCompleted();

  mTestSubscriber.assertValues("Two");
  mTestSubscriber.assertNoErrors();
  mTestSubscriber.assertCompleted();
}
 
开发者ID:ChunyuanCai,项目名称:PocketBeer,代码行数:14,代码来源:RxAsyncSubjectTester.java

示例2:

import rx.subjects.Subject; //导入方法依赖的package包/类
@Test
public void should_emits_all_items_and_call_onComplete_without_throwing_exception_when_ReplaySubject_without_error() {
  Subject<String, String> replaySubject = ReplaySubject.<String>create();

  replaySubject.subscribe(mTestSubscriber);
  replaySubject.onNext("One");
  replaySubject.onNext("Two");
  replaySubject.onCompleted();

  mTestSubscriber.assertValues("One", "Two");
  mTestSubscriber.assertNoErrors();
  mTestSubscriber.assertCompleted();
}
 
开发者ID:ChunyuanCai,项目名称:PocketBeer,代码行数:14,代码来源:RxReplaySubjectTester.java

示例3: should_still_emits_all_items_and_throw_exception_but_not_onComplete_when_ReplaySubject_with_error

import rx.subjects.Subject; //导入方法依赖的package包/类
@Test
public void should_still_emits_all_items_and_throw_exception_but_not_onComplete_when_ReplaySubject_with_error() {
  Subject<String, String> replaySubject = ReplaySubject.<String>create();

  replaySubject.subscribe(mTestSubscriber);
  replaySubject.onNext("One");
  replaySubject.onNext("Two");
  replaySubject.onError(new RuntimeException("Error occurs"));
  replaySubject.onCompleted();

  mTestSubscriber.assertValues("One", "Two");
  mTestSubscriber.assertError(RuntimeException.class);
  mTestSubscriber.assertNotCompleted();
}
 
开发者ID:ChunyuanCai,项目名称:PocketBeer,代码行数:15,代码来源:RxReplaySubjectTester.java

示例4: should_also_emit_item_from_subscriber_when_subscriber_executes_onNext_from_the_same_thread

import rx.subjects.Subject; //导入方法依赖的package包/类
@Test
public void should_also_emit_item_from_subscriber_when_subscriber_executes_onNext_from_the_same_thread() {
  Subject<String, String> replaySubject = ReplaySubject.<String>create();

  replaySubject.subscribe(mTestSubscriber);
  replaySubject.onNext("One");
  replaySubject.onNext("Two");
  mTestSubscriber.onNext("Three");
  replaySubject.onCompleted();

  mTestSubscriber.assertValues("One", "Two", "Three");
  mTestSubscriber.assertNoErrors();
  mTestSubscriber.assertCompleted();
}
 
开发者ID:ChunyuanCai,项目名称:PocketBeer,代码行数:15,代码来源:RxReplaySubjectTester.java

示例5: completeResponse

import rx.subjects.Subject; //导入方法依赖的package包/类
/**
 * Fulfill and complete the response observable.
 *
 * When called directly, this method completes on the event loop, but it can also be used in a callback (see
 * {@link #scheduleDirect(CoreScheduler, CouchbaseResponse, Subject)} for example.
 */
private static void completeResponse(final CouchbaseResponse response,
    final Subject<CouchbaseResponse, CouchbaseResponse> observable) {
    try {
        observable.onNext(response);
        observable.onCompleted();
    } catch (Exception ex) {
        LOGGER.warn("Caught exception while onNext on observable", ex);
        observable.onError(ex);
    }
}
 
开发者ID:couchbase,项目名称:couchbase-jvm-core,代码行数:17,代码来源:AbstractGenericHandler.java

示例6: emitSuccess

import rx.subjects.Subject; //导入方法依赖的package包/类
/**
 * Handle publishing the length and completed to the Subject.
 *
 * @param stream  Stream to get the length from
 */
private void emitSuccess(@NotNull LengthOfOutputStream stream) {
    Subject<Long, Long> lengthBroadcaster = stream.getLengthBroadcaster();
    lengthBroadcaster.onNext(stream.getResponseLength());
    lengthBroadcaster.onCompleted();
}
 
开发者ID:yahoo,项目名称:fili,代码行数:11,代码来源:BardLoggingFilter.java

示例7: onDestroy

import rx.subjects.Subject; //导入方法依赖的package包/类
void onDestroy() {
    log("onDestroy");
    for (Subject subject : mSubjects.values()) {
        subject.onCompleted();
    }
}
 
开发者ID:mugku,项目名称:RuntimePermissionsHelper,代码行数:7,代码来源:RxPermissions.java


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