本文整理了Java中io.reactivex.common.Notification.isOnComplete()
方法的一些代码示例,展示了Notification.isOnComplete()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Notification.isOnComplete()
方法的具体详情如下:
包路径:io.reactivex.common.Notification
类名称:Notification
方法名:isOnComplete
[英]Returns true if this notification is an onComplete signal.
[中]如果此通知是未完成信号,则返回true。
代码示例来源:origin: akarnokd/RxJava3-preview
if (nextNotification.isOnComplete()) {
return false;
代码示例来源:origin: akarnokd/RxJava3-preview
@Test
public void testMaterialize2() {
final TestAsyncErrorObservable o1 = new TestAsyncErrorObservable("one", "two", "three");
TestNotificationSubscriber subscriber = new TestNotificationSubscriber();
Flowable<Notification<String>> m = Flowable.unsafeCreate(o1).materialize();
m.subscribe(subscriber);
try {
o1.t.join();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
assertFalse(subscriber.onError);
assertTrue(subscriber.onComplete);
assertEquals(4, subscriber.notifications.size());
assertTrue(subscriber.notifications.get(0).isOnNext());
assertEquals("one", subscriber.notifications.get(0).getValue());
assertTrue(subscriber.notifications.get(1).isOnNext());
assertEquals("two", subscriber.notifications.get(1).getValue());
assertTrue(subscriber.notifications.get(2).isOnNext());
assertEquals("three", subscriber.notifications.get(2).getValue());
assertTrue(subscriber.notifications.get(3).isOnComplete());
}
代码示例来源:origin: akarnokd/RxJava3-preview
@Test
public void testMaterialize2() {
final TestAsyncErrorObservable o1 = new TestAsyncErrorObservable("one", "two", "three");
TestLocalObserver observer = new TestLocalObserver();
Observable<Notification<String>> m = Observable.unsafeCreate(o1).materialize();
m.subscribe(observer);
try {
o1.t.join();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
assertFalse(observer.onError);
assertTrue(observer.onComplete);
assertEquals(4, observer.notifications.size());
assertTrue(observer.notifications.get(0).isOnNext());
assertEquals("one", observer.notifications.get(0).getValue());
assertTrue(observer.notifications.get(1).isOnNext());
assertEquals("two", observer.notifications.get(1).getValue());
assertTrue(observer.notifications.get(2).isOnNext());
assertEquals("three", observer.notifications.get(2).getValue());
assertTrue(observer.notifications.get(3).isOnComplete());
}
代码示例来源:origin: akarnokd/RxJava3-preview
private boolean moveToNext() {
if (!started) {
started = true;
// if not started, start now
observer.setWaiting();
new ObservableMaterialize<T>(items).subscribe(observer);
}
Notification<T> nextNotification;
try {
nextNotification = observer.takeNext();
} catch (InterruptedException e) {
observer.dispose();
error = e;
throw ExceptionHelper.wrapOrThrow(e);
}
if (nextNotification.isOnNext()) {
isNextConsumed = false;
next = nextNotification.getValue();
return true;
}
// If an observable is completed or fails,
// hasNext() always return false.
hasNext = false;
if (nextNotification.isOnComplete()) {
return false;
}
error = nextNotification.getError();
throw ExceptionHelper.wrapOrThrow(error);
}
代码示例来源:origin: akarnokd/RxJava3-preview
@Override
public void onNext(Notification<T> t) {
if (done) {
if (t.isOnError()) {
RxJavaCommonPlugins.onError(t.getError());
}
return;
}
if (t.isOnError()) {
s.cancel();
onError(t.getError());
}
else if (t.isOnComplete()) {
s.cancel();
onComplete();
} else {
actual.onNext(t.getValue());
}
}
代码示例来源:origin: akarnokd/RxJava3-preview
@Override
public void onNext(Notification<T> t) {
if (done) {
if (t.isOnError()) {
RxJavaCommonPlugins.onError(t.getError());
}
return;
}
if (t.isOnError()) {
s.dispose();
onError(t.getError());
}
else if (t.isOnComplete()) {
s.dispose();
onComplete();
} else {
actual.onNext(t.getValue());
}
}
代码示例来源:origin: com.github.akarnokd.rxjava3/rxjava3-observable
@Override
public void onNext(Notification<T> t) {
if (done) {
if (t.isOnError()) {
RxJavaCommonPlugins.onError(t.getError());
}
return;
}
if (t.isOnError()) {
s.dispose();
onError(t.getError());
}
else if (t.isOnComplete()) {
s.dispose();
onComplete();
} else {
actual.onNext(t.getValue());
}
}
代码示例来源:origin: com.github.akarnokd.rxjava3/rxjava3-observable
private boolean moveToNext() {
if (!started) {
started = true;
// if not started, start now
observer.setWaiting();
new ObservableMaterialize<T>(items).subscribe(observer);
}
Notification<T> nextNotification;
try {
nextNotification = observer.takeNext();
} catch (InterruptedException e) {
observer.dispose();
error = e;
throw ExceptionHelper.wrapOrThrow(e);
}
if (nextNotification.isOnNext()) {
isNextConsumed = false;
next = nextNotification.getValue();
return true;
}
// If an observable is completed or fails,
// hasNext() always return false.
hasNext = false;
if (nextNotification.isOnComplete()) {
return false;
}
error = nextNotification.getError();
throw ExceptionHelper.wrapOrThrow(error);
}
代码示例来源:origin: akarnokd/RxJava3-preview
@Test
public void valueOfOnCompleteIsNull() {
Notification<Integer> notification = Notification.createOnComplete();
assertNull(notification.getValue());
assertNull(notification.getError());
assertTrue(notification.isOnComplete());
}
代码示例来源:origin: akarnokd/RxJava3-preview
@Test
public void testBackpressureOnEmptyStream() {
TestSubscriber<Notification<Integer>> ts = new TestSubscriber<Notification<Integer>>(0L);
Flowable.<Integer> empty().materialize().subscribe(ts);
ts.assertNoValues();
ts.request(1);
ts.assertValueCount(1);
assertTrue(ts.values().get(0).isOnComplete());
ts.assertComplete();
}
代码示例来源:origin: akarnokd/RxJava3-preview
@Test
public void nextObserverOnCompleteOnNext() throws Exception {
NextSubscriber<Integer> no = new NextSubscriber<Integer>();
no.setWaiting();
no.onNext(Notification.<Integer>createOnComplete());
no.setWaiting();
no.onNext(Notification.createOnNext(1));
assertTrue(no.takeNext().isOnComplete());
}
代码示例来源:origin: akarnokd/RxJava3-preview
@Test
public void nextObserverOnCompleteOnNext() throws Exception {
NextObserver<Integer> no = new NextObserver<Integer>();
no.setWaiting();
no.onNext(Notification.<Integer>createOnComplete());
no.setWaiting();
no.onNext(Notification.createOnNext(1));
assertTrue(no.takeNext().isOnComplete());
}
}
内容来源于网络,如有侵权,请联系作者删除!