當前位置: 首頁>>代碼示例>>Java>>正文


Java SingleObserver.onError方法代碼示例

本文整理匯總了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);
        }
    };
}
 
開發者ID:salesforce,項目名稱:reactive-grpc,代碼行數:25,代碼來源:SubscribeOnlyOnceSingleOperator.java

示例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();
}
 
開發者ID:davidmoten,項目名稱:rxjava2-jdbc,代碼行數:19,代碼來源:MemberSingle.java

示例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);
    }
}
 
開發者ID:roadhouse-dev,項目名稱:RxDbflow,代碼行數:17,代碼來源:DBFlowBaseSingle.java

示例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();
}
 
開發者ID:resilience4j,項目名稱:resilience4j,代碼行數:17,代碼來源:CircuitBreakerSingleObserverTest.java

示例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);
}
 
開發者ID:resilience4j,項目名稱:resilience4j,代碼行數:17,代碼來源:BulkheadSingleObserverTest.java

示例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);
        }
    };
}
 
開發者ID:google,項目名稱:science-journal,代碼行數:24,代碼來源:MaybeConsumers.java


注:本文中的io.reactivex.SingleObserver.onError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。