本文整理匯總了Java中io.reactivex.SingleObserver.onError方法的典型用法代碼示例。如果您正苦於以下問題:Java SingleObserver.onError方法的具體用法?Java SingleObserver.onError怎麽用?Java SingleObserver.onError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.reactivex.SingleObserver
的用法示例。
在下文中一共展示了SingleObserver.onError方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: apply
import io.reactivex.SingleObserver; //導入方法依賴的package包/類
@Override
public SingleObserver<? super T> apply(final SingleObserver<? super T> observer) {
return new SingleObserver<T>() {
@Override
public void onSubscribe(Disposable d) {
if (subscribedOnce.getAndSet(true)) {
throw new NullPointerException("You cannot directly subscribe to a gRPC service multiple times " +
"concurrently. Use Flowable.share() instead.");
} else {
observer.onSubscribe(d);
}
}
@Override
public void onSuccess(T t) {
observer.onSuccess(t);
}
@Override
public void onError(Throwable e) {
observer.onError(e);
}
};
}
示例2: subscribeActual
import io.reactivex.SingleObserver; //導入方法依賴的package包/類
@Override
protected void subscribeActual(SingleObserver<? super Member<T>> observer) {
// the action of checking out a member from the pool is implemented as a
// subscription to the singleton MemberSingle
MemberSingleObserver<T> md = new MemberSingleObserver<T>(observer, this);
observer.onSubscribe(md);
if (pool.isClosed()) {
observer.onError(new PoolClosedException());
return;
}
add(md);
if (md.isDisposed()) {
remove(md);
}
requested.incrementAndGet();
log.debug("subscribed");
drain();
}
示例3: subscribeActual
import io.reactivex.SingleObserver; //導入方法依賴的package包/類
@Override
protected void subscribeActual(SingleObserver<? super Container> observer) {
observer.onSubscribe(EmptyDisposable.INSTANCE);
try {
Container v = run();
if (v != null) {
observer.onSuccess(v);
} else {
observer.onError(new NullPointerException("The callable returned a null value"));
}
} catch (Throwable e) {
Exceptions.throwIfFatal(e);
observer.onError(e);
}
}
示例4: shouldHonorDisposedWhenCallingOnError
import io.reactivex.SingleObserver; //導入方法依賴的package包/類
@Test
public void shouldHonorDisposedWhenCallingOnError() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
SingleObserver childObserver = mock(SingleObserver.class);
SingleObserver decoratedObserver = CircuitBreakerOperator.of(circuitBreaker).apply(childObserver);
decoratedObserver.onSubscribe(disposable);
// When
((Disposable) decoratedObserver).dispose();
decoratedObserver.onError(new IllegalStateException());
// Then
verify(childObserver, never()).onError(any());
assertSingleFailedCall();
}
示例5: shouldHonorDisposedWhenCallingOnError
import io.reactivex.SingleObserver; //導入方法依賴的package包/類
@Test
public void shouldHonorDisposedWhenCallingOnError() throws Exception {
// Given
Disposable disposable = mock(Disposable.class);
SingleObserver childObserver = mock(SingleObserver.class);
SingleObserver decoratedObserver = BulkheadOperator.of(bulkhead).apply(childObserver);
decoratedObserver.onSubscribe(disposable);
// When
((Disposable) decoratedObserver).dispose();
decoratedObserver.onError(new IllegalStateException());
// Then
verify(childObserver, never()).onError(any());
assertThat(bulkhead.getMetrics().getAvailableConcurrentCalls()).isEqualTo(1);
}
示例6: fromSingleObserver
import io.reactivex.SingleObserver; //導入方法依賴的package包/類
/**
* MaybeConsumer<T> is very similar to {@link SingleObserver<T>} in JavaRX. Both are
* looking for either a signal that a computation has succeeded and returned a value of type
* T, or that it has failed with some exception. For the time period where we are still using
* both interfaces, we will find it useful to be able to switch between them.
*
* @return a {@link MaybeConsumer<T>} that pipes {@link MaybeConsumer#success(Object)}
* to {@link SingleObserver#onSuccess(Object)}, and {@link MaybeConsumer#fail(Exception)} to
* {@link SingleObserver#onError(Throwable)}
*/
public static <T> MaybeConsumer<T> fromSingleObserver(final SingleObserver<T> o) {
return new MaybeConsumer<T>() {
@Override
public void success(T value) {
o.onSuccess(value);
}
@Override
public void fail(Exception e) {
o.onError(e);
}
};
}