Interface CompletableObserver
- All Known Implementing Classes:
CompletableSubject, DisposableCompletableObserver, ResourceCompletableObserver, TestObserver
When a CompletableObserver is subscribed to a CompletableSource through the CompletableSource.subscribe(CompletableObserver) method,
the CompletableSource calls onSubscribe(Disposable) with a Disposable that allows
disposing the sequence at any time. A well-behaved
CompletableSource will call a CompletableObserver's onError(Throwable)
or onComplete() method exactly once as they are considered mutually exclusive terminal signals.
Calling the CompletableObserver's method must happen in a serialized fashion, that is, they must not
be invoked concurrently by multiple threads in an overlapping fashion and the invocation pattern must
adhere to the following protocol:
onSubscribe (onError | onComplete)?
Subscribing a CompletableObserver to multiple CompletableSources is not recommended. If such reuse
happens, it is the duty of the CompletableObserver implementation to be ready to receive multiple calls to
its methods and ensure proper concurrent behavior of its business logic.
Calling onSubscribe(Disposable) or onError(Throwable) with a
null argument is forbidden.
The implementations of the onXXX methods should avoid throwing runtime exceptions other than the following cases:
- If the argument is
null, the methods can throw aNullPointerException. Note though that RxJava preventsnulls to enter into the flow and thus there is generally no need to check for nulls in flows assembled from standard sources and intermediate operators. - If there is a fatal error (such as
VirtualMachineError).
- Since:
- 2.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidCalled once the deferred computation completes normally.voidCalled once if the deferred computation 'throws' an exception.voidCalled once by theCompletableto set aDisposableon this instance which then can be used to cancel the subscription at any time.
-
Method Details
-
onSubscribe
Called once by theCompletableto set aDisposableon this instance which then can be used to cancel the subscription at any time.- Parameters:
d- theDisposableinstance to call dispose on for cancellation, not null
-
onComplete
void onComplete()Called once the deferred computation completes normally. -
onError
-