- Type Parameters:
T- item type
- All Superinterfaces:
Flow.Publisher<T>
- All Known Implementing Classes:
CompletionSingle,ConcatPublisher,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.Publisherto downstream.<U> Subscribable<U> flatMapIterable(Function<? super T, ? extends Iterable<? extends U>> mapper) Transform item with supplied function and flatten resultingIterableto downstream.<U> Subscribable<U> Re-emit the upstream's signals to the downstream on the given executor's thread.Executes givenRunnablewhen a cancel signal is received.onComplete(Runnable onComplete) Executes givenRunnablewhen 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 givenRunnablewhen onError signal is received.onErrorResume(Function<? super Throwable, ? extends T> onError) Functionproviding 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 givenRunnablewhen 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 voidSubscribe to thisSingleinstance with the given delegate functions.default voidSubscribe to thisSingleinstance with the given delegate functions.default voidsubscribe(Consumer<? super T> consumer, Consumer<? super Throwable> errorConsumer, Runnable completeConsumer) Subscribe to thisSingleinstance with the given delegate functions.default voidsubscribe(Consumer<? super T> consumer, Consumer<? super Throwable> errorConsumer, Runnable completeConsumer, Consumer<? super Flow.Subscription> subscriptionConsumer) Subscribe to thisSingleinstance 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 aTimeoutExceptionif 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 thisSingleinstance with the given delegate functions.- Parameters:
consumer- onNext delegate function
-
subscribe
Subscribe to thisSingleinstance 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 thisSingleinstance 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 thisSingleinstance 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- ifdefaultItemisnull
-
defaultIfEmpty
Signals the default item supplied by specified supplier if the upstream is empty.- Parameters:
supplier- of the default value- Returns:
- Multi
- Throws:
NullPointerException- ifsupplierisnull
-
flatMap
Transform item with supplied function and flatten resultingFlow.Publisherto downstream.- Type Parameters:
U- output item type- Parameters:
mapper-Functionreceiving item as parameter and returningFlow.Publisher- Returns:
- Subscribable
-
flatMapIterable
Transform item with supplied function and flatten resultingIterableto 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- ifexecutorisnull
-
onCancel
Executes givenRunnablewhen a cancel signal is received.- Parameters:
onCancel-Runnableto be executed.- Returns:
- Subscribable
-
onComplete
Executes givenRunnablewhen onComplete signal is received.- Parameters:
onComplete-Runnableto be executed.- Returns:
- Subscribable
-
onError
Executes givenRunnablewhen onError signal is received.- Parameters:
onErrorConsumer-Consumerto 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
Functionproviding one item to be submitted as onNext in case of onError signal is received.- Parameters:
onError- Function receivingThrowableas argument and producing one item to resume stream with.- Returns:
- Subscribable
-
onCompleteResume
Resume stream from single item if onComplete signal is intercepted. Effectively do anappendto 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 givenRunnablewhen any of signals onComplete, onCancel or onError is received.- Parameters:
onTerminate-Runnableto 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- ifcountis negative- See Also:
-
retry
Retry a failing upstream if the predicate returns true.- Parameters:
predicate- the predicate that receives the latest failureThrowablethe number of times the retry happened so far (0-based) and should returntrueto retry the upstream again orfalseto signal the latest failure- Returns:
- Subscribable
- Throws:
NullPointerException- ifpredicateisnull- 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 failureThrowablethe number of times the retry happened so far (0-based) and should return aFlow.Publisherthat 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- ifwhenFunctionisnull
-
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- ifotherisnull
-
timeout
Signals aTimeoutExceptionif 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- ifunitorexecutorisnull
-