Calling unsubscribe() and isUnsubscribed() is thread-safe and can happen at any time, even
before or during an active rx. 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();
}
}
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final AsyncCompletableSubscriber. | UNSUBSCRIBED
Indicates the unsubscribed state. |
| private final AtomicReference | upstream
Holds onto a deferred subscription and allows asynchronous cancellation before the call to onSubscribe() by the upstream. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected final void | |
| public final boolean | isUnsubscribed()
Implements rx. Subscription is currently unsubscribed.
|
| protected void | |
| public final void | onSubscribe(Subscription
the Subscription instance to call dispose on for cancellation, not null d)Implements rx. |
| public final void | unsubscribe()
Implements rx. Subscriber that was registered when this Subscription
was received.
|
| UNSUBSCRIBED | back to summary |
|---|---|
| pack-priv static final AsyncCompletableSubscriber. Indicates the unsubscribed state. | |
| upstream | back to summary |
|---|---|
| private final AtomicReference<Subscription> upstream Holds onto a deferred subscription and allows asynchronous cancellation before the call to onSubscribe() by the upstream. | |
| AsyncCompletableSubscriber | back to summary |
|---|---|
| public AsyncCompletableSubscriber() | |
| clear | back to summary |
|---|---|
| protected final void clear() Call to clear the upstream's subscription without unsubscribing it. | |
| isUnsubscribed | back to summary |
|---|---|
| public final boolean isUnsubscribed() Implements rx. Doc from rx. Indicates whether this
| |
| onStart | back to summary |
|---|---|
| protected void onStart() Called before the first onSubscribe() call succeeds. | |
| onSubscribe | back to summary |
|---|---|
| public final void onSubscribe(Subscription d) Implements rx. Doc from rx. Called once by the Completable to set a Subscription on this instance which then can be used to cancel the subscription at any time.
| |
| unsubscribe | back to summary |
|---|---|
| public final void unsubscribe() Implements rx. Doc from rx. Stops the receipt of notifications on the
This allows deregistering an
| |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | isUnsubscribed()
Implements rx. Subscription is currently unsubscribed.
|
| public void | unsubscribe()
Implements rx. Subscriber that was registered when this Subscription
was received.
|
| Unsubscribed | back to summary |
|---|---|
| pack-priv Unsubscribed() | |
| isUnsubscribed | back to summary |
|---|---|
| public boolean isUnsubscribed() Implements rx. Doc from rx. Indicates whether this
| |
| unsubscribe | back to summary |
|---|---|
| public void unsubscribe() Implements rx. Doc from rx. Stops the receipt of notifications on the
This allows deregistering an
| |