本文整理了Java中io.reactivex.common.Notification.getValue()
方法的一些代码示例,展示了Notification.getValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Notification.getValue()
方法的具体详情如下:
包路径:io.reactivex.common.Notification
类名称:Notification
方法名:getValue
[英]Returns the contained value if this notification is an onNext signal, null otherwise.
[中]如果此通知是onNext信号,则返回包含的值,否则返回null。
代码示例来源:origin: com.github.akarnokd.rxjava3/rxjava3-observable
@Override
public T next() {
if (hasNext()) {
T v = iteratorNotification.getValue();
iteratorNotification = null;
return v;
}
throw new NoSuchElementException();
}
代码示例来源:origin: akarnokd/RxJava3-preview
@Override
public T next() {
if (hasNext()) {
T v = iteratorNotification.getValue();
iteratorNotification = null;
return v;
}
throw new NoSuchElementException();
}
代码示例来源:origin: akarnokd/RxJava3-preview
@Override
public T next() {
if (hasNext()) {
if (iteratorNotification.isOnNext()) {
T v = iteratorNotification.getValue();
iteratorNotification = null;
return v;
}
}
throw new NoSuchElementException();
}
代码示例来源:origin: akarnokd/RxJava3-preview
@SuppressWarnings("rawtypes")
static String value(Notification notification) {
if (notification.isOnNext()) {
return String.valueOf(notification.getValue());
}
return "null";
}
代码示例来源:origin: akarnokd/RxJava3-preview
@SuppressWarnings("rawtypes")
static String value(Notification notification) {
if (notification.isOnNext()) {
return String.valueOf(notification.getValue());
}
return "null";
}
代码示例来源: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
@Test
public void valueOfOnErrorIsNull() {
Notification<Integer> notification = Notification.createOnError(new TestException());
assertNull(notification.getValue());
assertTrue(notification.getError().toString(), notification.getError() instanceof TestException);
}
代码示例来源:origin: akarnokd/RxJava3-preview
@Test
public void testMaterialize1() {
// null will cause onError to be triggered before "three" can be
// returned
final TestAsyncErrorObservable o1 = new TestAsyncErrorObservable("one", "two", null,
"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(3, 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).isOnError());
assertEquals(NullPointerException.class, observer.notifications.get(2).getError().getClass());
}
代码示例来源:origin: akarnokd/RxJava3-preview
@Test
public void testMaterialize1() {
// null will cause onError to be triggered before "three" can be
// returned
final TestAsyncErrorObservable o1 = new TestAsyncErrorObservable("one", "two", null,
"three");
TestNotificationSubscriber observer = new TestNotificationSubscriber();
Flowable<Notification<String>> m = Flowable.unsafeCreate(o1).materialize();
m.subscribe(observer);
try {
o1.t.join();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
assertFalse(observer.onError);
assertTrue(observer.onComplete);
assertEquals(3, 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).isOnError());
assertEquals(NullPointerException.class, observer.notifications.get(2).getError().getClass());
}
代码示例来源:origin: akarnokd/RxJava3-preview
if (nextNotification.isOnNext()) {
isNextConsumed = false;
next = nextNotification.getValue();
return true;
代码示例来源: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 nextObserverOnNext() throws Exception {
NextObserver<Integer> no = new NextObserver<Integer>();
no.setWaiting();
no.onNext(Notification.createOnNext(1));
no.setWaiting();
no.onNext(Notification.createOnNext(1));
assertEquals(1, no.takeNext().getValue().intValue());
}
代码示例来源:origin: akarnokd/RxJava3-preview
@Test
public void nextObserverOnNext() throws Exception {
NextSubscriber<Integer> no = new NextSubscriber<Integer>();
no.setWaiting();
no.onNext(Notification.createOnNext(1));
no.setWaiting();
no.onNext(Notification.createOnNext(1));
assertEquals(1, no.takeNext().getValue().intValue());
}
代码示例来源:origin: akarnokd/RxJava3-preview
@Test
public void valueOfOnCompleteIsNull() {
Notification<Integer> notification = Notification.createOnComplete();
assertNull(notification.getValue());
assertNull(notification.getError());
assertTrue(notification.isOnComplete());
}
内容来源于网络,如有侵权,请联系作者删除!