public abstract class

Subject

extends Observable<T>
implements Observer<T>
java.lang.Object
   ↳ io.reactivex.Observable<T>
     ↳ io.reactivex.subjects.Subject<T>
Known Direct Subclasses

Class Overview

Represents an Observer and an Observable at the same time, allowing multicasting events from a single source to multiple child Subscribers.

All methods except the onSubscribe, onNext, onError and onComplete are thread-safe. Use toSerialized() to make these methods thread-safe as well.

Summary

Public Constructors
Subject()
Public Methods
abstract Throwable getThrowable()
Returns the error that caused the Subject to terminate or null if the Subject hasn't terminated yet.
abstract boolean hasComplete()
Returns true if the subject has reached a terminal state through a complete event.
abstract boolean hasObservers()
Returns true if the subject has any Observers.
abstract boolean hasThrowable()
Returns true if the subject has reached a terminal state through an error event.
final Subject<T> toSerialized()
Wraps this Subject and serializes the calls to the onSubscribe, onNext, onError and onComplete methods, making them thread-safe.
[Expand]
Inherited Methods
From class io.reactivex.Observable
From class java.lang.Object
From interface io.reactivex.ObservableSource
From interface io.reactivex.Observer

Public Constructors

public Subject ()

Public Methods

public abstract Throwable getThrowable ()

Returns the error that caused the Subject to terminate or null if the Subject hasn't terminated yet.

The method is thread-safe.

Returns
  • the error that caused the Subject to terminate or null if the Subject hasn't terminated yet

public abstract boolean hasComplete ()

Returns true if the subject has reached a terminal state through a complete event.

The method is thread-safe.

Returns
  • true if the subject has reached a terminal state through a complete event
See Also

public abstract boolean hasObservers ()

Returns true if the subject has any Observers.

The method is thread-safe.

Returns
  • true if the subject has any Observers

public abstract boolean hasThrowable ()

Returns true if the subject has reached a terminal state through an error event.

The method is thread-safe.

Returns
  • true if the subject has reached a terminal state through an error event

public final Subject<T> toSerialized ()

Wraps this Subject and serializes the calls to the onSubscribe, onNext, onError and onComplete methods, making them thread-safe.

The method is thread-safe.

Returns
  • the wrapped and serialized subject