SingleObserver that 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.
Calling onSuccess(Object) multiple times has no effect.
Calling onError(Throwable) multiple times or after onSuccess will route the
exception into the global error handler via io..
The emitter allows the registration of a single resource, in the form of a Disposable
or Cancellable via setDisposable(Disposable) or setCancellable(Cancellable)
respectively. The emitter implementations will dispose/cancel this instance when the
downstream cancels the flow or after the event generator logic calls onSuccess(Object),
onError(Throwable), or when tryOnError(Throwable) succeeds.
Only one Disposable or 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 io.
and associate that with the emitter instead.
The 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
io..
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the downstream disposed the sequence or the emitter was terminatedReturns true if the downstream disposed the sequence or the
emitter was terminated via |
| public void | |
| public void | |
| public void | setCancellable(Cancellable
the cancellable resource, null is allowed c)Sets a Cancellable on this emitter; any previous |
| public void | setDisposable(Disposable
the disposable, null is allowed d)Sets a Disposable on this emitter; any previous Disposable or Cancellable will be disposed/cancelled. |
| public boolean | Returns: true if successful, false if the downstream is not able to accept further eventsthe throwable error to signal if possible t)Attempts to emit the specified |
| isDisposed | back to summary |
|---|---|
| public boolean isDisposed() Returns true if the downstream disposed the sequence or the
emitter was terminated via This method is thread-safe.
| |
| onError | back to summary |
|---|---|
| public void onError(Throwable t) Signal an exception.
| |
| onSuccess | back to summary |
|---|---|
| public void onSuccess(T t) Signal a success value.
| |
| setCancellable | back to summary |
|---|---|
| public void setCancellable(Cancellable c) Sets a Cancellable on this emitter; any previous
| |
| setDisposable | back to summary |
|---|---|
| public void setDisposable(Disposable d) Sets a Disposable on this emitter; any previous Disposable or Cancellable will be disposed/cancelled.
| |
| tryOnError | back to summary |
|---|---|
| public boolean tryOnError(Throwable t) Attempts to emit the specified
Unlike History: 2.1.1 - experimental
| |