org.reactivestreams.Subscriber that allows associating
a resource with it and exposes the current number of downstream
requested amount.
The onNext(Object), onError(Throwable), tryOnError(Throwable)
and onComplete() methods should be called in a sequential manner, just like
the Subscriber's methods.
Use the FlowableEmitter the serialize() method returns instead of the original
FlowableEmitter 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 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 onError(Throwable),
onComplete() 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 cancelled the sequence or the emitter was terminatedReturns true if the downstream cancelled the sequence or the
emitter was terminated via |
| public long | |
| public @NonNull FlowableEmitter | Returns: the serializedFlowableEmitterEnsures that calls to |
| public void | setCancellable(@Nullable Cancellable
the c)Cancellable resource, null is allowedSets a |
| public void | setDisposable(@Nullable Disposable
the disposable, d)null is allowedSets a Disposable on this emitter; any previous |
| 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 |
| isCancelled | back to summary |
|---|---|
| public boolean isCancelled() Returns true if the downstream cancelled the sequence or the
emitter was terminated via This method is thread-safe.
| |
| requested | back to summary |
|---|---|
| public long requested() The current outstanding request amount. This method is thread-safe.
| |
| serialize | back to summary |
|---|---|
| public @NonNull FlowableEmitter Ensures that calls to
| |
| setCancellable | back to summary |
|---|---|
| public void setCancellable(@Nullable Cancellable c) Sets a This method is thread-safe.
| |
| setDisposable | back to summary |
|---|---|
| public void setDisposable(@Nullable Disposable d) Sets a Disposable on this emitter; any previous This method is thread-safe.
| |
| tryOnError | back to summary |
|---|---|
| public boolean tryOnError(@NonNull Throwable t) Attempts to emit the specified
Unlike History: 2.1.1 - experimental | |