public final class

CompletableSubject

extends Completable
implements CompletableObserver
java.lang.Object
   ↳ io.reactivex.Completable
     ↳ io.reactivex.subjects.CompletableSubject

Class Overview

Represents a hot Completable-like source and consumer of events similar to Subjects.

All methods are thread safe. Calling onComplete multiple times has no effect. Calling onError multiple times relays the Throwable to the RxJavaPlugins' error handler.

The CompletableSubject doesn't store the Disposables coming through onSubscribe but disposes them once the other onXXX methods were called (terminal state reached).

History: 2.0.5 - experimental

Summary

Public Methods
static CompletableSubject create()
Creates a fresh CompletableSubject.
Throwable getThrowable()
Returns the terminal error if this CompletableSubject has been terminated with an error, null otherwise.
boolean hasComplete()
Returns true if this CompletableSubject has been completed.
boolean hasObservers()
Returns true if this CompletableSubject has observers.
boolean hasThrowable()
Returns true if this CompletableSubject has been terminated with an error.
void onComplete()
Called once the deferred computation completes normally.
void onError(Throwable e)
Called once if the deferred computation 'throws' an exception.
void onSubscribe(Disposable d)
Called once by the Completable to set a Disposable on this instance which then can be used to cancel the subscription at any time.
Protected Methods
void subscribeActual(CompletableObserver observer)
Implement this to handle the incoming CompletableObserver and perform the business logic in your operator.
[Expand]
Inherited Methods
From class io.reactivex.Completable
From class java.lang.Object
From interface io.reactivex.CompletableObserver
From interface io.reactivex.CompletableSource

Public Methods

public static CompletableSubject create ()

Creates a fresh CompletableSubject.

Returns
  • the new CompletableSubject instance

public Throwable getThrowable ()

Returns the terminal error if this CompletableSubject has been terminated with an error, null otherwise.

Returns
  • the terminal error or null if not terminated or not with an error

public boolean hasComplete ()

Returns true if this CompletableSubject has been completed.

Returns
  • true if this CompletableSubject has been completed

public boolean hasObservers ()

Returns true if this CompletableSubject has observers.

Returns
  • true if this CompletableSubject has observers

public boolean hasThrowable ()

Returns true if this CompletableSubject has been terminated with an error.

Returns
  • true if this CompletableSubject has been terminated with an error

public void onComplete ()

Called once the deferred computation completes normally.

public void onError (Throwable e)

Called once if the deferred computation 'throws' an exception.

Parameters
e the exception, not null.

public void onSubscribe (Disposable d)

Called once by the Completable to set a Disposable on this instance which then can be used to cancel the subscription at any time.

Parameters
d the Disposable instance to call dispose on for cancellation, not null

Protected Methods

protected void subscribeActual (CompletableObserver observer)

Implement this to handle the incoming CompletableObserver and perform the business logic in your operator.

Parameters
observer the CompletableObserver instance, never null