Top Description Inners Fields Constructors Methods
rx.observers

public abstract Class AsyncCompletableSubscriber

extends Object
implements CompletableSubscriber, Subscription
Class Inheritance
All Implemented Interfaces
rx.Subscription, rx.CompletableSubscriber
Imports
java.util.concurrent.atomic.AtomicReference, rx.CompletableSubscriber, .Subscription, rx.plugins.RxJavaHooks

An abstract base class for CompletableSubscriber implementations that want to expose an unsubscription capability.

Calling unsubscribe() and isUnsubscribed() is thread-safe and can happen at any time, even before or during an active rx.Completable#subscribe(CompletableSubscriber) call.

Override the onStart() method to execute custom logic on the very first successful onSubscribe call.

If one wants to remain consistent regarding isUnsubscribed() and being terminated, the clear() method should be called from the implementing onError and onCompleted methods.


public final class MyCompletableSubscriber extends AsyncCompletableSubscriber {
    @Override
    public void onStart() {
        System.out.println("Started!");
    }

    @Override
    public void onCompleted() {
        System.out.println("Completed!");
        clear();
    }

    @Override
    public void onError(Throwable e) {
        e.printStackTrace();
        clear();
    }
}
Since
1.3

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv static final AsyncCompletableSubscriber.Unsubscribed
UNSUBSCRIBED

Indicates the unsubscribed state.

private final AtomicReference<Subscription>
upstream

Holds onto a deferred subscription and allows asynchronous cancellation before the call to onSubscribe() by the upstream.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected final void
clear()

Call to clear the upstream's subscription without unsubscribing it.

public final boolean
isUnsubscribed()

Implements rx.Subscription.isUnsubscribed.

Indicates whether this Subscription is currently unsubscribed.
protected void
onStart()

Called before the first onSubscribe() call succeeds.

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

Implements rx.CompletableSubscriber.onSubscribe.

Called once by the Completable to set a Subscription on this instance which then can be used to cancel the subscription at any time.
public final void
unsubscribe()

Implements rx.Subscription.unsubscribe.

Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

UNSUBSCRIBEDback to summary
pack-priv static final AsyncCompletableSubscriber.Unsubscribed UNSUBSCRIBED

Indicates the unsubscribed state.

upstreamback to summary
private final AtomicReference<Subscription> upstream

Holds onto a deferred subscription and allows asynchronous cancellation before the call to onSubscribe() by the upstream.

Constructor Detail

AsyncCompletableSubscriberback to summary
public AsyncCompletableSubscriber()

Method Detail

clearback to summary
protected final void clear()

Call to clear the upstream's subscription without unsubscribing it.

isUnsubscribedback to summary
public final boolean isUnsubscribed()

Implements rx.Subscription.isUnsubscribed.

Doc from rx.Subscription.isUnsubscribed.

Indicates whether this Subscription is currently unsubscribed.

Returns:boolean

true if this Subscription is currently unsubscribed, false otherwise

Annotations
@Override
onStartback to summary
protected void onStart()

Called before the first onSubscribe() call succeeds.

onSubscribeback to summary
public final void onSubscribe(Subscription d)

Implements rx.CompletableSubscriber.onSubscribe.

Doc from rx.CompletableSubscriber.onSubscribe.

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

Parameters
d:Subscription

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

Annotations
@Override
unsubscribeback to summary
public final void unsubscribe()

Implements rx.Subscription.unsubscribe.

Doc from rx.Subscription.unsubscribe.

Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.

This allows deregistering an Subscriber before it has finished receiving all events (i.e. before onCompleted is called).

Annotations
@Override
rx.observers back to summary

pack-priv final Class AsyncCompletableSubscriber.Unsubscribed

extends Object
implements Subscription
Class Inheritance
All Implemented Interfaces
rx.Subscription

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public boolean
isUnsubscribed()

Implements rx.Subscription.isUnsubscribed.

Indicates whether this Subscription is currently unsubscribed.
public void
unsubscribe()

Implements rx.Subscription.unsubscribe.

Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Unsubscribedback to summary
pack-priv Unsubscribed()

Method Detail

isUnsubscribedback to summary
public boolean isUnsubscribed()

Implements rx.Subscription.isUnsubscribed.

Doc from rx.Subscription.isUnsubscribed.

Indicates whether this Subscription is currently unsubscribed.

Returns:boolean

true if this Subscription is currently unsubscribed, false otherwise

Annotations
@Override
unsubscribeback to summary
public void unsubscribe()

Implements rx.Subscription.unsubscribe.

Doc from rx.Subscription.unsubscribe.

Stops the receipt of notifications on the Subscriber that was registered when this Subscription was received.

This allows deregistering an Subscriber before it has finished receiving all events (i.e. before onCompleted is called).

Annotations
@Override