T- the value type to emit
public interface ObservableEmitter<T> extends Emitter<T>
Observerthat allows associating a resource with it.
Emitter.onComplete() methods should be called in a sequential manner, just like the
Observer's methods should be.
serialize() method returns instead of the original
ObservableEmitter instance provided by the generator routine if you want to ensure this.
The other methods are thread-safe.
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
Emitter.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|
Ensures that calls to onNext, onError and onComplete are properly serialized.
Sets a Cancellable on this emitter; any previous Disposable or Cancellation will be unsubscribed/cancelled.
Sets a Disposable on this emitter; any previous Disposable or Cancellation will be unsubscribed/cancelled.
Attempts to emit the specified
void setDisposable(@Nullable Disposable d)
d- the disposable, null is allowed
void setCancellable(@Nullable Cancellable c)
c- the cancellable resource, null is allowed
Emitter.onComplete()or a successful
This method is thread-safe.
@NonNull ObservableEmitter<T> serialize()
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