Class BlockingMultiObserver<T>

java.lang.Object
java.util.concurrent.CountDownLatch
io.reactivex.rxjava3.internal.observers.BlockingMultiObserver<T>
Type Parameters:
T - the value type
All Implemented Interfaces:
CompletableObserver, MaybeObserver<T>, SingleObserver<T>

public final class BlockingMultiObserver<T> extends CountDownLatch implements SingleObserver<T>, CompletableObserver, MaybeObserver<T>
A combined Observer that awaits the success or error signal via a CountDownLatch.
  • Field Details

    • value

      T value
    • error

      Throwable error
    • upstream

      Disposable upstream
    • cancelled

      volatile boolean cancelled
  • Constructor Details

    • BlockingMultiObserver

      public BlockingMultiObserver()
  • Method Details

    • dispose

      void dispose()
    • onSubscribe

      public void onSubscribe(Disposable d)
      Description copied from interface: SingleObserver
      Provides the SingleObserver with the means of cancelling (disposing) the connection (channel) with the Single in both synchronous (from within onSubscribe(Disposable) itself) and asynchronous manner.
      Specified by:
      onSubscribe in interface CompletableObserver
      Specified by:
      onSubscribe in interface MaybeObserver<T>
      Specified by:
      onSubscribe in interface SingleObserver<T>
      Parameters:
      d - the Disposable instance whose Disposable.dispose() can be called anytime to cancel the connection
    • onSuccess

      public void onSuccess(T value)
      Description copied from interface: SingleObserver
      Notifies the SingleObserver with a single item and that the Single has finished sending push-based notifications.

      The Single will not call this method if it calls SingleObserver.onError(java.lang.Throwable).

      Specified by:
      onSuccess in interface MaybeObserver<T>
      Specified by:
      onSuccess in interface SingleObserver<T>
      Parameters:
      value - the item emitted by the Single
    • onError

      public void onError(Throwable e)
      Description copied from interface: SingleObserver
      Notifies the SingleObserver that the Single has experienced an error condition.

      If the Single calls this method, it will not thereafter call SingleObserver.onSuccess(T).

      Specified by:
      onError in interface CompletableObserver
      Specified by:
      onError in interface MaybeObserver<T>
      Specified by:
      onError in interface SingleObserver<T>
      Parameters:
      e - the exception encountered by the Single
    • onComplete

      public void onComplete()
      Description copied from interface: CompletableObserver
      Called once the deferred computation completes normally.
      Specified by:
      onComplete in interface CompletableObserver
      Specified by:
      onComplete in interface MaybeObserver<T>
    • blockingGet

      public T blockingGet()
      Block until the latch is counted down then rethrow any exception received (wrapped if checked) or return the received value (null if none).
      Returns:
      the value received or null if no value received
    • blockingGet

      public T blockingGet(T defaultValue)
      Block until the latch is counted down then rethrow any exception received (wrapped if checked) or return the received value (the defaultValue if none).
      Parameters:
      defaultValue - the default value to return if no value was received
      Returns:
      the value received or defaultValue if no value received
    • blockingAwait

      public boolean blockingAwait(long timeout, TimeUnit unit)
      Block until the observer terminates and return true; return false if the wait times out.
      Parameters:
      timeout - the timeout value
      unit - the time unit
      Returns:
      true if the observer terminated in time, false otherwise
    • blockingConsume

      public void blockingConsume(Consumer<? super T> onSuccess, Consumer<? super Throwable> onError, Action onComplete)
      Blocks until the source completes and calls the appropriate callback.
      Parameters:
      onSuccess - for a succeeding source
      onError - for a failing source
      onComplete - for an empty source