public interface

SingleEmitter

io.reactivex.SingleEmitter<T>

Class Overview

Abstraction over an RxJava SingleObserver that allows associating a resource with it.

All methods are safe to call from multiple threads.

Calling onSuccess or onError multiple times has no effect.

Summary

Public Methods
abstract boolean isDisposed()
Returns true if the downstream cancelled the sequence.
abstract void onError(Throwable t)
Signal an exception.
abstract void onSuccess(T t)
Signal a success value.
abstract void setCancellable(Cancellable c)
Sets a Cancellable on this emitter; any previous Disposable or Cancellation will be unsubscribed/cancelled.
abstract void setDisposable(Disposable s)
Sets a Disposable on this emitter; any previous Disposable or Cancellation will be unsubscribed/cancelled.
abstract boolean tryOnError(Throwable t)
Attempts to emit the specified Throwable error if the downstream hasn't cancelled the sequence or is otherwise terminated, returning false if the emission is not allowed to happen due to lifecycle restrictions.

Public Methods

public abstract boolean isDisposed ()

Returns true if the downstream cancelled the sequence.

Returns
  • true if the downstream cancelled the sequence

public abstract void onError (Throwable t)

Signal an exception.

Parameters
t the exception, not null

public abstract void onSuccess (T t)

Signal a success value.

Parameters
t the value, not null

public abstract void setCancellable (Cancellable c)

Sets a Cancellable on this emitter; any previous Disposable or Cancellation will be unsubscribed/cancelled.

Parameters
c the cancellable resource, null is allowed

public abstract void setDisposable (Disposable s)

Sets a Disposable on this emitter; any previous Disposable or Cancellation will be unsubscribed/cancelled.

Parameters
s the disposable, null is allowed

public abstract boolean tryOnError (Throwable t)

Attempts to emit the specified Throwable error if the downstream hasn't cancelled the sequence or is otherwise terminated, returning false if the emission is not allowed to happen due to lifecycle restrictions.

Unlike onError(Throwable), the RxJavaPlugins.onError is not called if the error could not be delivered.

Parameters
t the throwable error to signal if possible
Returns
  • true if successful, false if the downstream is not able to accept further events