Java Code Examples for io.reactivex.CompletableObserver#onError()

The following examples show how to use io.reactivex.CompletableObserver#onError() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompletableErrorProxyOperator.java    From ETHWallet with GNU General Public License v3.0 6 votes vote down vote up
@Override
public CompletableObserver apply(CompletableObserver observer) throws Exception {
    return new DisposableCompletableObserver() {
        @Override
        public void onComplete() {
            if (!isDisposed()) {
                observer.onError(throwable);
            }
        }

        @Override
        public void onError(Throwable ex) {
            if (!isDisposed()) {
                observer.onError(ex);
            }
        }
    };
}
 
Example 2
Source File: CompletableErrorProxyOperator.java    From trust-wallet-android-source with GNU General Public License v3.0 6 votes vote down vote up
@Override
public CompletableObserver apply(CompletableObserver observer) throws Exception {
    return new DisposableCompletableObserver() {
        @Override
        public void onComplete() {
            if (!isDisposed()) {
                observer.onError(throwable);
            }
        }

        @Override
        public void onError(Throwable ex) {
            if (!isDisposed()) {
                observer.onError(ex);
            }
        }
    };
}
 
Example 3
Source File: CompletableRateLimiter.java    From resilience4j with Apache License 2.0 6 votes vote down vote up
@Override
protected void subscribeActual(CompletableObserver downstream) {
    long waitDuration = rateLimiter.reservePermission();
    if (waitDuration >= 0) {
        if (waitDuration > 0) {
            Completable.timer(waitDuration, TimeUnit.NANOSECONDS)
                .subscribe(
                    () -> upstream.subscribe(new RateLimiterCompletableObserver(downstream)));
        } else {
            upstream.subscribe(new RateLimiterCompletableObserver(downstream));
        }
    } else {
        downstream.onSubscribe(EmptyDisposable.INSTANCE);
        downstream.onError(RequestNotPermitted.createRequestNotPermitted(rateLimiter));
    }
}
 
Example 4
Source File: RxWebAuthClientImpl.java    From samples-android with Apache License 2.0 5 votes vote down vote up
@Override
public Completable logIn(@NonNull FragmentActivity activity, AuthenticationPayload payload) {
    return new Completable() {
        @Override
        protected void subscribeActual(CompletableObserver observer) {
            try {
                mSyncAuthClient.signIn(activity, payload);
                observer.onComplete();
            } catch (InterruptedException e) {
                processLogInResult(Result.cancel());
                observer.onError(e);
            }
        }
    };
}
 
Example 5
Source File: RxWebAuthClientImpl.java    From samples-android with Apache License 2.0 5 votes vote down vote up
@Override
public Completable signOutOfOkta(@NonNull FragmentActivity activity) {
    return new Completable() {
        @Override
        protected void subscribeActual(CompletableObserver observer) {
            try {
                mSyncAuthClient.signOutOfOkta(activity);
                observer.onComplete();
            } catch (InterruptedException e) {
                processSignOutResult(Result.cancel());
                observer.onError(e);
            }
        }
    };
}
 
Example 6
Source File: MaybeConsumers.java    From science-journal with Apache License 2.0 5 votes vote down vote up
/**
 * MaybeConsumer<Success> is very similar to {@link CompletableObserver} in JavaRX. Both are
 * looking for either a signal that a process has succeeded, 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<Success>} that pipes {@link MaybeConsumer#success(Object)} to
 *     {@link CompletableObserver#onComplete()}, and {@link MaybeConsumer#fail(Exception)} to
 *     {@link CompletableObserver#onError(Throwable)}
 */
public static MaybeConsumer<Success> fromCompletableObserver(final CompletableObserver o) {
  return new MaybeConsumer<Success>() {
    @Override
    public void success(Success value) {
      o.onComplete();
    }

    @Override
    public void fail(Exception e) {
      o.onError(e);
    }
  };
}
 
Example 7
Source File: CompletableCircuitBreaker.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Override
protected void subscribeActual(CompletableObserver downstream) {
    if (circuitBreaker.tryAcquirePermission()) {
        upstream.subscribe(new CircuitBreakerCompletableObserver(downstream));
    } else {
        downstream.onSubscribe(EmptyDisposable.INSTANCE);
        downstream.onError(createCallNotPermittedException(circuitBreaker));
    }
}
 
Example 8
Source File: CompletableBulkhead.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@Override
protected void subscribeActual(CompletableObserver downstream) {
    if (bulkhead.tryAcquirePermission()) {
        upstream.subscribe(new BulkheadCompletableObserver(downstream));
    } else {
        downstream.onSubscribe(EmptyDisposable.INSTANCE);
        downstream.onError(BulkheadFullException.createBulkheadFullException(bulkhead));
    }
}