本文整理汇总了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();
}
}