public interface CompletableEmitter
CompletableObserverthat allows associating a resource with it.
All methods are safe to call from multiple threads, but note that there is no guarantee whose terminal event will win and get delivered to the downstream.
onComplete() multiple times has no effect.
onError(Throwable) multiple times or after
onComplete will route the
exception into the global error handler via
The emitter allows the registration of a single resource, in the form of a
respectively. The emitter implementations will dispose/cancel this instance when the
downstream cancels the flow or after the event generator logic calls
onComplete() or when
Cancellable object can be associated with the emitter at
a time. Calling either
set method will dispose/cancel any previous object. If there
is a need for handling multiple resources, one can create a
and associate that with the emitter instead.
Cancellable is logically equivalent to
Disposable but allows using cleanup logic that can
throw a checked exception (such as many
close() methods on Java IO components). Since
the release of resources happens after the terminal events have been delivered or the sequence gets
cancelled, exceptions throw within
Cancellable are routed to the global error handler via
|Modifier and Type||Method and Description|
Signal the completion.
Signal an exception.
Sets a Cancellable on this emitter; any previous Disposable or Cancellation will be disposed/cancelled.
Sets a Disposable on this emitter; any previous Disposable or Cancellation will be disposed/cancelled.
Attempts to emit the specified
t- the exception, not null
void setDisposable(@Nullable Disposable d)
d- the disposable, null is allowed
void setCancellable(@Nullable Cancellable c)
c- the cancellable resource, null is allowed
onComplete()or a successful
This method is thread-safe.
Throwableerror if the downstream hasn't cancelled the sequence or is otherwise terminated, returning false if the emission is not allowed to happen due to lifecycle restrictions.
RxJavaPlugins.onError is not called
if the error could not be delivered.
t- the throwable error to signal if possible