本文整理匯總了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
示例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();
}
示例7: onDestroy
import rx.subjects.Subject; //導入方法依賴的package包/類
void onDestroy() {
log("onDestroy");
for (Subject subject : mSubjects.values()) {
subject.onCompleted();
}
}