- Type Parameters:
T
- item type
- All Superinterfaces:
Flow.Publisher<T>
- All Known Implementing Classes:
CompletionSingle
,ConcatPublisher
,MessageBodyReadableContent
,MultiFromOutputStream
,MultiTappedPublisher
,OutputStreamMulti
Decorated publisher that allows subscribing to individual events with java functions.
-
Method Summary
Modifier and TypeMethodDescriptiondefaultIfEmpty
(Supplier<? extends T> supplier) Signals the default item supplied by specified supplier if the upstream is empty.defaultIfEmpty
(T defaultItem) Signals the default item if the upstream is empty.<U> Subscribable<U>
flatMap
(Function<? super T, ? extends Flow.Publisher<? extends U>> mapper) Transform item with supplied function and flatten resultingFlow.Publisher
to downstream.<U> Subscribable<U>
flatMapIterable
(Function<? super T, ? extends Iterable<? extends U>> mapper) Transform item with supplied function and flatten resultingIterable
to downstream.<U> Subscribable<U>
Re-emit the upstream's signals to the downstream on the given executor's thread.Executes givenRunnable
when a cancel signal is received.onComplete
(Runnable onComplete) Executes givenRunnable
when onComplete signal is received.onCompleteResume
(T item) Resume stream from single item if onComplete signal is intercepted.onCompleteResumeWith
(Flow.Publisher<? extends T> publisher) Resume stream from supplied publisher if onComplete signal is intercepted.Executes givenRunnable
when onError signal is received.onErrorResume
(Function<? super Throwable, ? extends T> onError) Function
providing one item to be submitted as onNext in case of onError signal is received.onErrorResumeWith
(Function<? super Throwable, ? extends Flow.Publisher<? extends T>> onError) Resume stream from supplied publisher if onError signal is intercepted.onTerminate
(Runnable onTerminate) Executes givenRunnable
when any of signals onComplete, onCancel or onError is received.Invoke provided consumer for every item in stream.retry
(long count) Retry a failing upstream at most the given number of times before giving up.retry
(BiPredicate<? super Throwable, ? super Long> predicate) Retry a failing upstream if the predicate returns true.<U> Subscribable<T>
retryWhen
(BiFunction<? super Throwable, ? super Long, ? extends Flow.Publisher<U>> whenFunction) Retry a failing upstream when the given function returns a publisher that signals an item.default void
Subscribe to thisSingle
instance with the given delegate functions.default void
Subscribe to thisSingle
instance with the given delegate functions.default void
subscribe
(Consumer<? super T> consumer, Consumer<? super Throwable> errorConsumer, Runnable completeConsumer) Subscribe to thisSingle
instance with the given delegate functions.default void
subscribe
(Consumer<? super T> consumer, Consumer<? super Throwable> errorConsumer, Runnable completeConsumer, Consumer<? super Flow.Subscription> subscriptionConsumer) Subscribe to thisSingle
instance with the given delegate functions.<U> Subscribable<T>
takeUntil
(Flow.Publisher<U> other) Relay upstream items until the other source signals an item or completes.timeout
(long timeout, TimeUnit unit, ScheduledExecutorService executor) Signals aTimeoutException
if the upstream doesn't signal the next item, error or completion within the specified time.Methods inherited from interface java.util.concurrent.Flow.Publisher
subscribe
-
Method Details
-
subscribe
Subscribe to thisSingle
instance with the given delegate functions.- Parameters:
consumer
- onNext delegate function
-
subscribe
Subscribe to thisSingle
instance with the given delegate functions.- Parameters:
consumer
- onNext delegate functionerrorConsumer
- onError delegate function
-
subscribe
default void subscribe(Consumer<? super T> consumer, Consumer<? super Throwable> errorConsumer, Runnable completeConsumer) Subscribe to thisSingle
instance with the given delegate functions.- Parameters:
consumer
- onNext delegate functionerrorConsumer
- onError delegate functioncompleteConsumer
- onComplete delegate function
-
subscribe
default void subscribe(Consumer<? super T> consumer, Consumer<? super Throwable> errorConsumer, Runnable completeConsumer, Consumer<? super Flow.Subscription> subscriptionConsumer) Subscribe to thisSingle
instance with the given delegate functions.- Parameters:
consumer
- onNext delegate functionerrorConsumer
- onError delegate functioncompleteConsumer
- onComplete delegate functionsubscriptionConsumer
- onSusbcribe delegate function
-
defaultIfEmpty
Signals the default item if the upstream is empty.- Parameters:
defaultItem
- the item to signal if the upstream is empty- Returns:
- Subscribable
- Throws:
NullPointerException
- ifdefaultItem
isnull
-
defaultIfEmpty
Signals the default item supplied by specified supplier if the upstream is empty.- Parameters:
supplier
- of the default value- Returns:
- Multi
- Throws:
NullPointerException
- ifsupplier
isnull
-
flatMap
Transform item with supplied function and flatten resultingFlow.Publisher
to downstream.- Type Parameters:
U
- output item type- Parameters:
mapper
-Function
receiving item as parameter and returningFlow.Publisher
- Returns:
- Subscribable
-
flatMapIterable
Transform item with supplied function and flatten resultingIterable
to downstream. -
map
- Type Parameters:
U
- mapped item type- Parameters:
mapper
- mapper- Returns:
- Subscribable
- Throws:
NullPointerException
- if mapper isnull
-
observeOn
Re-emit the upstream's signals to the downstream on the given executor's thread.- Parameters:
executor
- the executor to signal the downstream from.- Returns:
- Subscribable
- Throws:
NullPointerException
- ifexecutor
isnull
-
onCancel
Executes givenRunnable
when a cancel signal is received.- Parameters:
onCancel
-Runnable
to be executed.- Returns:
- Subscribable
-
onComplete
Executes givenRunnable
when onComplete signal is received.- Parameters:
onComplete
-Runnable
to be executed.- Returns:
- Subscribable
-
onError
Executes givenRunnable
when onError signal is received.- Parameters:
onErrorConsumer
-Consumer
to be executed.- Returns:
- Subscribable
-
onErrorResumeWith
Subscribable<T> onErrorResumeWith(Function<? super Throwable, ? extends Flow.Publisher<? extends T>> onError) Resume stream from supplied publisher if onError signal is intercepted.- Parameters:
onError
- supplier of new stream publisher- Returns:
- Subscribable
-
onErrorResume
Function
providing one item to be submitted as onNext in case of onError signal is received.- Parameters:
onError
- Function receivingThrowable
as argument and producing one item to resume stream with.- Returns:
- Subscribable
-
onCompleteResume
Resume stream from single item if onComplete signal is intercepted. Effectively do anappend
to the stream.- Parameters:
item
- one item to resume stream with- Returns:
- Subscribable
-
onCompleteResumeWith
Resume stream from supplied publisher if onComplete signal is intercepted.- Parameters:
publisher
- new stream publisher- Returns:
- Subscribable
-
onTerminate
Executes givenRunnable
when any of signals onComplete, onCancel or onError is received.- Parameters:
onTerminate
-Runnable
to be executed.- Returns:
- Subscribable
-
peek
Invoke provided consumer for every item in stream.- Parameters:
consumer
- consumer to be invoked- Returns:
- Subscribable
-
retry
Retry a failing upstream at most the given number of times before giving up.- Parameters:
count
- the number of times to retry; 0 means no retry at all- Returns:
- Subscribable
- Throws:
IllegalArgumentException
- ifcount
is negative- See Also:
-
retry
Retry a failing upstream if the predicate returns true.- Parameters:
predicate
- the predicate that receives the latest failureThrowable
the number of times the retry happened so far (0-based) and should returntrue
to retry the upstream again orfalse
to signal the latest failure- Returns:
- Subscribable
- Throws:
NullPointerException
- ifpredicate
isnull
- See Also:
-
retryWhen
<U> Subscribable<T> retryWhen(BiFunction<? super Throwable, ? super Long, ? extends Flow.Publisher<U>> whenFunction) Retry a failing upstream when the given function returns a publisher that signals an item.If the publisher returned by the function completes, the repetition stops and this Subscribable is completed. If the publisher signals an error, the repetition stops and this Subscribable will signal this error.
- Type Parameters:
U
- the element type of the retry-signal sequence- Parameters:
whenFunction
- the function that receives the latest failureThrowable
the number of times the retry happened so far (0-based) and should return aFlow.Publisher
that should signal an item to retry again, complete to stop and complete this Subscribable or signal an error to have this Subscribable emit that error as well.- Returns:
- Subscribable
- Throws:
NullPointerException
- ifwhenFunction
isnull
-
takeUntil
Relay upstream items until the other source signals an item or completes.- Type Parameters:
U
- the element type of the other sequence- Parameters:
other
- the other sequence to signal the end of the main sequence- Returns:
- Subscribable
- Throws:
NullPointerException
- ifother
isnull
-
timeout
Signals aTimeoutException
if the upstream doesn't signal the next item, error or completion within the specified time.- Parameters:
timeout
- the time to wait for the upstream to signalunit
- the time unitexecutor
- the executor to use for waiting for the upstream signal- Returns:
- Subscribable
- Throws:
NullPointerException
- ifunit
orexecutor
isnull
-