當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。