Top Description Fields Constructors Methods
io.reactivex.observers

public abstract Class DisposableCompletableObserver

extends Object
implements CompletableObserver, Disposable
Class Inheritance
All Implemented Interfaces
io.reactivex.disposables.Disposable, io.reactivex.CompletableObserver
Imports
java.util.concurrent.atomic.AtomicReference, io.reactivex.CompletableObserver, io.reactivex.annotations.NonNull, io.reactivex.disposables.Disposable, io.reactivex.internal.disposables.DisposableHelper, io.reactivex.internal.util.EndConsumerHelper

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();

Field Summary

Modifier and TypeField and Description
pack-priv final AtomicReference<Disposable>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final void
dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.
public final boolean
isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.
protected void
onStart()

Called once the single upstream Disposable is set via onSubscribe.

public final void
onSubscribe(Disposable
the Disposable instance to call dispose on for cancellation, not null
d
)

Implements io.reactivex.CompletableObserver.onSubscribe.

Called once by the Completable to set a Disposable on this instance which then can be used to cancel the subscription at any time.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

upstreamback to summary
pack-priv final AtomicReference<Disposable> upstream

Constructor Detail

DisposableCompletableObserverback to summary
public DisposableCompletableObserver()

Method Detail

disposeback to summary
public final void dispose()

Implements io.reactivex.disposables.Disposable.dispose.

Doc from io.reactivex.disposables.Disposable.dispose.

Dispose the resource, the operation should be idempotent.

Annotations
@Override
isDisposedback to summary
public final boolean isDisposed()

Implements io.reactivex.disposables.Disposable.isDisposed.

Doc from io.reactivex.disposables.Disposable.isDisposed.

Returns true if this resource has been disposed.

Returns:boolean

true if this resource has been disposed

Annotations
@Override
onStartback to summary
protected void onStart()

Called once the single upstream Disposable is set via onSubscribe.

onSubscribeback to summary
public final void onSubscribe(Disposable d)

Implements io.reactivex.CompletableObserver.onSubscribe.

Doc from io.reactivex.CompletableObserver.onSubscribe.

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:Disposable

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

Annotations
@Override