public interface

ObservableEmitter

implements Emitter<T>
io.reactivex.ObservableEmitter<T>

Class Overview

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

The onNext, onError and onComplete methods should be called in a sequential manner, just like the Observer's methods. Use serialize() if you want to ensure this. The other methods are thread-safe.

Summary

Public Methods
abstract boolean isDisposed()
Returns true if the downstream disposed the sequence.
abstract ObservableEmitter<T> serialize()
Ensures that calls to onNext, onError and onComplete are properly serialized.
abstract void setCancellable(Cancellable c)
Sets a Cancellable on this emitter; any previous Disposable or Cancellation will be unsubscribed/cancelled.
abstract void setDisposable(Disposable d)
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.
[Expand]
Inherited Methods
From interface io.reactivex.Emitter

Public Methods

public abstract boolean isDisposed ()

Returns true if the downstream disposed the sequence.

Returns
  • true if the downstream disposed the sequence

public abstract ObservableEmitter<T> serialize ()

Ensures that calls to onNext, onError and onComplete are properly serialized.

Returns
  • the serialized ObservableEmitter

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 d)

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

Parameters
d 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