- java.lang.Object
- 
- io.helidon.common.reactive.EmittingPublisher<T>
 
- 
- Type Parameters:
- T- type of emitted item
 - All Implemented Interfaces:
- Flow.Publisher<T>
 
 public class EmittingPublisher<T> extends Object implements Flow.Publisher<T> Emitting publisher for manual publishing on the same thread.EmittingPublisherdoesn't have any buffering capability and propagates backpressure directly by returningfalsefromemit(Object)in case there is no demand, orcancelsignal has been received.For publishing with buffering in case of backpressure use BufferedEmittingPublisher.This publisher allows only a single subscriber. 
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcomplete()Properly complete the stream, set publisher to completed state and sendonCompletesignal downstream.static <T> EmittingPublisher<T>create()Create newEmittingPublisher.booleanemit(T item)Emit one item to the stream, if there is enough requested and publisher is not cancelled, item is signaled to downstream asonNextand method returns true.voidfail(Throwable throwable)Properly fail the stream, set publisher to cancelled state and sendonErrorsignal downstream.Optional<Throwable>failCause()Return cause of fail, if publisher is in failed state.booleanhasRequests()Check if demand is higher than 0.booleanisCancelled()Check if publisher has been cancelled.booleanisCompleted()Check if publisher has been completed.booleanisFailed()Check if publisher has been failed.booleanisUnbounded()Check if downstream requested unbounded number of items, eg.voidonCancel(Runnable cancelCallback)Executed when cancel signal from downstream arrive.voidonRequest(BiConsumer<Long,Long> requestCallback)Callback executed when request signal from downstream arrive.voidsubscribe(Flow.Subscriber<? super T> subscriber)
 
- 
- 
- 
Method Detail- 
createpublic static <T> EmittingPublisher<T> create() Create newEmittingPublisher.- Type Parameters:
- T- type of emitted item
- Returns:
- brand new EmittingPublisher
 
 - 
subscribepublic void subscribe(Flow.Subscriber<? super T> subscriber) - Specified by:
- subscribein interface- Flow.Publisher<T>
 
 - 
failpublic void fail(Throwable throwable) Properly fail the stream, set publisher to cancelled state and sendonErrorsignal downstream. SignalonErroris sent only once, any other call to this method is no-op.- Parameters:
- throwable- Sent as- onErrorsignal
 
 - 
completepublic void complete() Properly complete the stream, set publisher to completed state and sendonCompletesignal downstream. SignalonCompleteis sent only once, any other call to this method is no-op.
 - 
emitpublic boolean emit(T item) Emit one item to the stream, if there is enough requested and publisher is not cancelled, item is signaled to downstream asonNextand method returns true. If there is requested less than 1, nothing is sent and method returns false.- Parameters:
- item- to be sent downstream
- Returns:
- true if item successfully sent, false if canceled or no demand
- Throws:
- IllegalStateException- if publisher is completed
 
 - 
isCompletedpublic boolean isCompleted() Check if publisher has been completed.- Returns:
- true if so
 
 - 
isCancelledpublic boolean isCancelled() Check if publisher has been cancelled.- Returns:
- true if so
 
 - 
isFailedpublic boolean isFailed() Check if publisher has been failed.- Returns:
- true if so
 
 - 
hasRequestspublic boolean hasRequests() Check if demand is higher than 0. Returned value should be used as informative and can change asynchronously.- Returns:
- true if so
 
 - 
isUnboundedpublic boolean isUnbounded() Check if downstream requested unbounded number of items, eg. there is no backpressure.- Returns:
- true if so
 
 - 
failCausepublic Optional<Throwable> failCause() Return cause of fail, if publisher is in failed state.- Returns:
- optional cause of fail
 
 - 
onCancelpublic void onCancel(Runnable cancelCallback) Executed when cancel signal from downstream arrive.- Parameters:
- cancelCallback- to be executed
 
 - 
onRequestpublic void onRequest(BiConsumer<Long,Long> requestCallback) Callback executed when request signal from downstream arrive.- param nthe requested count.
- param resultthe current total cumulative requested count, ranges between [0,Long.MAX_VALUE] where the max indicates that this publisher is unbounded.
 - Parameters:
- requestCallback- to be executed
 
- param 
 
- 
 
-