public abstract class

DisposableCompletableObserver

extends Object
implements CompletableObserver Disposable
java.lang.Object
   ↳ io.reactivex.observers.DisposableCompletableObserver

Class Overview

An abstract CompletableObserver that allows asynchronous cancellation by implementing Disposable.

All pre-implemented final methods are thread-safe.

Like all other consumers, DisposableCompletableObserver can be subscribed only once. Any subsequent attempt to subscribe it to a new source will yield an IllegalStateException with message "It is not allowed to subscribe with a(n) <class name> multiple times.".

Implementation of onStart(), onError(Throwable) and onComplete() are not allowed to throw any unchecked exceptions.

Example


 Disposable d =
     Completable.complete().delay(1, TimeUnit.SECONDS)
     .subscribeWith(new DisposableMaybeObserver<Integer>() {
         @Override public void onStart() {
             System.out.println("Start!");
         }
         @Override public void onError(Throwable t) {
             t.printStackTrace();
         }
         @Override public void onComplete() {
             System.out.println("Done!");
         }
     });
 // ...
 d.dispose();
 

Summary

Public Constructors
DisposableCompletableObserver()
Public Methods
final void dispose()
Dispose the resource, the operation should be idempotent.
final boolean isDisposed()
Returns true if this resource has been disposed.
final void onSubscribe(Disposable s)
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 onStart()
Called once the single upstream Disposable is set via onSubscribe.
[Expand]
Inherited Methods
From class java.lang.Object
From interface io.reactivex.CompletableObserver
From interface io.reactivex.disposables.Disposable

Public Constructors

public DisposableCompletableObserver ()

Public Methods

public final void dispose ()

Dispose the resource, the operation should be idempotent.

public final boolean isDisposed ()

Returns true if this resource has been disposed.

Returns
  • true if this resource has been disposed

public final void onSubscribe (Disposable s)

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
s the Disposable instance to call dispose on for cancellation, not null

Protected Methods

protected void onStart ()

Called once the single upstream Disposable is set via onSubscribe.