- Type Parameters:
T- item type
- All Superinterfaces:
Flow.Publisher<T>,Subscribable<T>
- All Known Implementing Classes:
ConcatPublisher,MultiFromOutputStream,MultiTappedPublisher,OutputStreamMulti
Flow.Publisher emitting zero or more items, optionally followed by
an error or completion.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault <U> Single<U> default <U> Single<U> collect(Supplier<? extends U> collectionSupplier, BiConsumer<U, T> accumulator) default <A,R> Single <R> collectStream(Collector<T, A, R> collector) Collects up upstream items with the help of a the callbacks of aCollector.default <U> Multi<U> compose(Function<? super Multi<T>, ? extends Flow.Publisher<? extends U>> composer) Apply the givencomposerfunction to the currentMultiinstance and return aMultiwrapping the returnedFlow.Publisherof this function.static <T> Multi<T> concat(Flow.Publisher<T> firstMulti, Flow.Publisher<T> secondMulti) Concat streams to one.static <T> Multi<T> concat(Flow.Publisher<T> firstPublisher, Flow.Publisher<T> secondPublisher, Flow.Publisher<T>... morePublishers) Concat streams to one.static <T> Multi<T> concatArray(Flow.Publisher<T>... publishers) Concatenates an array of sourceFlow.Publishers by relaying items in order, non-overlappingly, one after the other finishes.static <T> Multi<T> static <T> Multi<T> Create aMultiinstance that publishes the given iterable.static <T> Multi<T> create(CompletionStage<T> completionStage) Wrap a CompletionStage into a Multi and signal its outcome non-blockingly.static <T> Multi<T> create(CompletionStage<T> completionStage, boolean nullMeansEmpty) Wrap a CompletionStage into a Multi and signal its outcome non-blockingly.static <T> Multi<T> create(Flow.Publisher<T> source) Create aMultiinstance wrapped around the given publisher.static <T> Multi<T> defaultIfEmpty(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.static <T> Multi<T> defer(Supplier<? extends Flow.Publisher<? extends T>> supplier) Call the given supplier function for each individual downstream Subscriber to return a Flow.Publisher to subscribe to.distinct()Filter out all duplicates.Drop the longest prefix of elements from this stream that satisfy the given predicate.static <T> Multi<T> empty()Get aMultiinstance that completes immediately.static <T> Multi<T> Create aMultiinstance that reports the given exception to its subscriber(s).Filter stream items with provided predicate.first()default <U> Multi<U> flatMap(Function<? super T, ? extends Flow.Publisher<? extends U>> publisherMapper) Transform item with supplied function and flatten resultingFlow.Publisherto downstream.default <U> Multi<U> flatMap(Function<? super T, ? extends Flow.Publisher<? extends U>> mapper, long maxConcurrency, boolean delayErrors, long prefetch) Transform item with supplied function and flatten resultingFlow.Publisherto downstream while limiting the maximum number of concurrent innerFlow.Publishers and their in-flight item count, optionally aggregating and delaying all errors until all sources terminate.default <U> Multi<U> flatMapCompletionStage(Function<? super T, ? extends CompletionStage<? extends U>> mapper) Transform item with supplied function and flatten resultingCompletionStageresults to downstream.default <U> Multi<U> flatMapIterable(Function<? super T, ? extends Iterable<? extends U>> iterableMapper) Transform item with supplied function and flatten resultingIterableto downstream.default <U> Multi<U> flatMapIterable(Function<? super T, ? extends Iterable<? extends U>> iterableMapper, int prefetch) Transform item with supplied function and flatten resultingIterableto downstream.default <U> Multi<U> flatMapOptional(Function<? super T, Optional<? extends U>> mapper) Transform item with supplied function and flatten resultingOptionalto downstream as one item if present or nothing if empty.Terminal stage, invokes provided consumer for every item in the stream with no backpressure.forEachCompletionStage(Function<? super T, CompletionStage<Void>> function) Terminal stage, invokes provided consumer for every item in the stream with strict backpressure.static <T> Multi<T> Deprecated.static <T> Multi<T> Deprecated.usecreate(java.lang.Iterable)insteadstatic <T> Multi<T> from(CompletionStage<T> completionStage) Deprecated.usecreate(java.util.concurrent.CompletionStage)insteadstatic <T> Multi<T> from(CompletionStage<T> completionStage, boolean nullMeansEmpty) Deprecated.static <T> Multi<T> from(Flow.Publisher<T> source) Deprecated.usecreate(java.util.concurrent.Flow.Publisher)insteadstatic <T> Multi<T> Deprecated.usecreate(java.util.stream.Stream)insteadExecutes givenRunnablewhen stream is finished without value(empty stream).Terminal stage, ignore all items and complete returnedSingle<Void>successfully or exceptionally.interval(long initialDelay, long period, TimeUnit unit, ScheduledExecutorService executor) Signal 0L after an initial delay, then 1L, 2L and so on periodically to the downstream.interval(long period, TimeUnit unit, ScheduledExecutorService executor) Signal 0L, 1L and so on periodically to the downstream.static <T> Multi<T> just(Collection<T> items) Create aMultiinstance that publishes the given items to a single subscriber.static <T> Multi<T> just(T... items) Create aMultiinstance that publishes the given items to a single subscriber.limit(long limit) Limit stream to allow only specified number of items to pass.log()Log all signalsonSubscribe,onNext,onError,onComplete,cancelandrequestcoming to and from preceding operator.Log all signalsonSubscribe,onNext,onError,onComplete,cancelandrequestcoming to and from preceding operator.Log all signalsonSubscribe,onNext,onError,onComplete,cancelandrequestcoming to and from preceding operator.Log all signalsonSubscribe,onNext,onError,onComplete,cancelandrequestcoming to and from preceding operator.default <U> Multi<U> static <T> Multi<T> never()Get aMultiinstance that never completes.Re-emit the upstream's signals to the downstream on the given executor's thread using a default buffer size of 32 and errors skipping ahead of items.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.range(int start, int count) Emits a range of ever increasing integers.rangeLong(long start, long count) Emits a range of ever increasing longs.reduce(BiFunction<T, T, T> reducer) Combine subsequent items via a callback function and emit the final value result as a Single.default <R> Single<R> reduce(Supplier<? extends R> supplier, BiFunction<R, T, R> reducer) Combine every upstream item with an accumulator value to produce a new accumulator value and emit the final accumulator value as a Single.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.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.static <T> Multi<T> singleton(T item) Create aMultithat emits a pre-existing item and then completes.skip(long skip) Skip first n items, all the others are emitted.switchIfEmpty(Flow.Publisher<T> other) Switch to the other publisher if the upstream is empty.takeUntil(Flow.Publisher<U> other) Relay upstream items until the other source signals an item or completes.Take the longest prefix of elements from this stream that satisfy the given predicate.timeout(long timeout, TimeUnit unit, ScheduledExecutorService executor) Signals aTimeoutExceptionif the upstream doesn't signal the next item, error or completion within the specified time.timeout(long timeout, TimeUnit unit, ScheduledExecutorService executor, Flow.Publisher<T> fallback) Switches to a fallback single if the upstream doesn't signal the next item, error or completion within the specified time.timer(long time, TimeUnit unit, ScheduledExecutorService executor) Signal 0L and complete the sequence after the given time elapsed.default <U> UApply the givenconverterfunction to the currentMultiinstance and return the value returned by this function.Methods inherited from interface java.util.concurrent.Flow.Publisher
subscribeMethods inherited from interface io.helidon.common.reactive.Subscribable
subscribe, subscribe, subscribe, subscribe
-
Method Details
-
concat
Concat streams to one.- Type Parameters:
T- item type- Parameters:
firstMulti- first streamsecondMulti- second stream- Returns:
- Multi
-
concat
@SafeVarargs static <T> Multi<T> concat(Flow.Publisher<T> firstPublisher, Flow.Publisher<T> secondPublisher, Flow.Publisher<T>... morePublishers) Concat streams to one.- Type Parameters:
T- item type- Parameters:
firstPublisher- first streamsecondPublisher- second streammorePublishers- more publishers to concat- Returns:
- Multi
-
concatArray
Concatenates an array of sourceFlow.Publishers by relaying items in order, non-overlappingly, one after the other finishes.- Type Parameters:
T- item type- Parameters:
publishers- more publishers to concat- Returns:
- Multi
-
defer
Call the given supplier function for each individual downstream Subscriber to return a Flow.Publisher to subscribe to.- Type Parameters:
T- the element type of the sequence- Parameters:
supplier- the callback to return a Flow.Publisher for each Subscriber- Returns:
- Multi
- Throws:
NullPointerException- ifsupplierisnull
-
empty
Get aMultiinstance that completes immediately.- Type Parameters:
T- item type- Returns:
- Multi
-
error
Create aMultiinstance that reports the given exception to its subscriber(s). The exception is reported by invokingFlow.Subscriber.onError(java.lang.Throwable)whenFlow.Publisher.subscribe(Subscriber)is called.- Type Parameters:
T- item type- Parameters:
error- exception to hold- Returns:
- Multi
- Throws:
NullPointerException- if error isnull
-
from
Deprecated.usecreate(java.util.concurrent.CompletionStage)insteadWrap a CompletionStage into a Multi and signal its outcome non-blockingly.A null result from the CompletionStage will yield a
NullPointerExceptionsignal.- Type Parameters:
T- the element type of the stage and result- Parameters:
completionStage- the CompletionStage to- Returns:
- Multi
- See Also:
-
from
Deprecated.Wrap a CompletionStage into a Multi and signal its outcome non-blockingly.- Type Parameters:
T- the element type of the stage and result- Parameters:
completionStage- the CompletionStage tonullMeansEmpty- if true, a null result is interpreted to be an empty sequence if false, the resulting sequence fails withNullPointerException- Returns:
- Multi
-
from
Deprecated.usecreate(java.lang.Iterable)insteadCreate aMultiinstance that publishes the given iterable.- Type Parameters:
T- item type- Parameters:
iterable- iterable to publish- Returns:
- Multi
- Throws:
NullPointerException- if iterable isnull
-
from
Deprecated.usecreate(java.util.concurrent.Flow.Publisher)insteadCreate aMultiinstance wrapped around the given publisher.- Type Parameters:
T- item type- Parameters:
source- source publisher- Returns:
- Multi
- Throws:
NullPointerException- if source isnull
-
from
Deprecated.usecreate(io.helidon.common.reactive.Single)instead- Type Parameters:
T- item type- Parameters:
single- sourceSinglepublisher- Returns:
- Multi
- Throws:
NullPointerException- if source isnull
-
from
Deprecated.usecreate(java.util.stream.Stream)insteadCreate aMultiinstance that publishes the givenStream.Note that Streams can be only consumed once, therefore, the returned Multi will signal
IllegalStateExceptionif multiple subscribers try to consume it.The operator calls
BaseStream.close()when the stream finishes, fails or the flow gets canceled. To avoid closing the stream automatically, it is recommended to turn theStreaminto anIterableviaBaseStream.iterator()and usecreate(Iterable):Stream<T> stream = ... Multi<T> multi = Multi.create(stream::iterator);- Type Parameters:
T- item type- Parameters:
stream- the Stream to publish- Returns:
- Multi
- Throws:
NullPointerException- ifstreamisnull
-
create
Wrap a CompletionStage into a Multi and signal its outcome non-blockingly.A null result from the CompletionStage will yield a
NullPointerExceptionsignal.- Type Parameters:
T- the element type of the stage and result- Parameters:
completionStage- the CompletionStage to- Returns:
- Multi
- See Also:
-
create
Wrap a CompletionStage into a Multi and signal its outcome non-blockingly.- Type Parameters:
T- the element type of the stage and result- Parameters:
completionStage- the CompletionStage tonullMeansEmpty- if true, a null result is interpreted to be an empty sequence if false, the resulting sequence fails withNullPointerException- Returns:
- Multi
-
create
Create aMultiinstance that publishes the given iterable.- Type Parameters:
T- item type- Parameters:
iterable- iterable to publish- Returns:
- Multi
- Throws:
NullPointerException- if iterable isnull
-
create
Create aMultiinstance wrapped around the given publisher.- Type Parameters:
T- item type- Parameters:
source- source publisher- Returns:
- Multi
- Throws:
NullPointerException- if source isnull
-
create
- Type Parameters:
T- item type- Parameters:
single- sourceSinglepublisher- Returns:
- Multi
- Throws:
NullPointerException- if source isnull
-
create
Create aMultiinstance that publishes the givenStream.Note that Streams can be only consumed once, therefore, the returned Multi will signal
IllegalStateExceptionif multiple subscribers try to consume it.The operator calls
BaseStream.close()when the stream finishes, fails or the flow gets canceled. To avoid closing the stream automatically, it is recommended to turn theStreaminto anIterableviaBaseStream.iterator()and usecreate(Iterable):Stream<T> stream = ... Multi<T> multi = Multi.create(stream::iterator);- Type Parameters:
T- item type- Parameters:
stream- the Stream to publish- Returns:
- Multi
- Throws:
NullPointerException- ifstreamisnull
-
interval
Signal 0L, 1L and so on periodically to the downstream.Note that if the downstream applies backpressure, subsequent values may be delivered instantly upon further requests from the downstream.
- Parameters:
period- the initial and in-between timeunit- the time unitexecutor- the scheduled executor to use for the periodic emission- Returns:
- Multi
- Throws:
NullPointerException- ifunitorexecutorisnull
-
interval
static Multi<Long> interval(long initialDelay, long period, TimeUnit unit, ScheduledExecutorService executor) Signal 0L after an initial delay, then 1L, 2L and so on periodically to the downstream.Note that if the downstream applies backpressure, subsequent values may be delivered instantly upon further requests from the downstream.
- Parameters:
initialDelay- the time before signaling 0Lperiod- the in-between wait time for values 1L, 2L and so onunit- the time unitexecutor- the scheduled executor to use for the periodic emission- Returns:
- Multi
- Throws:
NullPointerException- ifunitorexecutorisnull
-
just
Create aMultiinstance that publishes the given items to a single subscriber.- Type Parameters:
T- item type- Parameters:
items- items to publish- Returns:
- Multi
- Throws:
NullPointerException- ifitemsisnull
-
just
Create aMultiinstance that publishes the given items to a single subscriber.- Type Parameters:
T- item type- Parameters:
items- items to publish- Returns:
- Multi
- Throws:
NullPointerException- ifitemsisnull
-
never
Get aMultiinstance that never completes.- Type Parameters:
T- item type- Returns:
- Multi
-
range
Emits a range of ever increasing integers.- Parameters:
start- the initial integer valuecount- the number of integers to emit- Returns:
- Multi
- Throws:
IllegalArgumentException- ifcountis negative
-
rangeLong
Emits a range of ever increasing longs.- Parameters:
start- the initial long valuecount- the number of longs to emit- Returns:
- Multi
- Throws:
IllegalArgumentException- ifcountis negative
-
singleton
Create aMultithat emits a pre-existing item and then completes.- Type Parameters:
T- the type of the item- Parameters:
item- the item to emit.- Returns:
- Multi
- Throws:
NullPointerException- ifitemisnull
-
timer
Signal 0L and complete the sequence after the given time elapsed.- Parameters:
time- the time to wait before signaling 0L and completionunit- the unit of timeexecutor- the executor to run the waiting on- Returns:
- Multi
- Throws:
NullPointerException- ifunitorexecutorisnull
-
collect
- Type Parameters:
U- collector container type- Parameters:
collector- collector to use- Returns:
- Single
- Throws:
NullPointerException- if collector isnull
-
collect
default <U> Single<U> collect(Supplier<? extends U> collectionSupplier, BiConsumer<U, T> accumulator) Collect the items of thisMultiinto a collection provided via aSupplierand mutated by aBiConsumercallback.- Type Parameters:
U- the type of the collection and result- Parameters:
collectionSupplier- theSupplierthat is called for each incomingFlow.Subscriberto create a fresh collection to collect items intoaccumulator- theBiConsumerthat receives the collection and the current item to put in- Returns:
- Single
- Throws:
NullPointerException- ifcollectionSupplierorcombinerisnull
-
collectList
- Returns:
- Single
-
collectStream
Collects up upstream items with the help of a the callbacks of aCollector.- Type Parameters:
A- the accumulator typeR- the result type- Parameters:
collector- the collector whosesupplier(),accumulator()andfinisher()callbacks are used for collecting upstream items into a final form.- Returns:
- Single
- Throws:
NullPointerException- ifcollectorisnull
-
compose
default <U> Multi<U> compose(Function<? super Multi<T>, ? extends Flow.Publisher<? extends U>> composer) Apply the givencomposerfunction to the currentMultiinstance and return aMultiwrapping the returnedFlow.Publisherof this function.Note that the
composerfunction is executed upon calling this method immediately and not when the resulting sequence gets subscribed to.- Type Parameters:
U- the output element type- Parameters:
composer- the function that receives the currentMultiinstance and should return aFlow.Publisherto be wrapped into aMultieto be returned by the method- Returns:
- Multi
- Throws:
NullPointerException- ifcomposerisnull
-
defaultIfEmpty
Signals the default item if the upstream is empty.- Specified by:
defaultIfEmptyin interfaceSubscribable<T>- Parameters:
defaultItem- the item to signal if the upstream is empty- Returns:
- Multi
- Throws:
NullPointerException- ifdefaultItemisnull
-
defaultIfEmpty
Signals the default item supplied by specified supplier if the upstream is empty.- Specified by:
defaultIfEmptyin interfaceSubscribable<T>- Parameters:
supplier- of the default value- Returns:
- Multi
- Throws:
NullPointerException- ifsupplierisnull
-
distinct
Filter out all duplicates.- Returns:
- Multi
-
dropWhile
Drop the longest prefix of elements from this stream that satisfy the given predicate. As long as predicate returns true, items from upstream are NOT sent to downstream but being dropped, predicate is never called again after it returns false for the first time.- Parameters:
predicate- predicate to filter stream with- Returns:
- Multi
-
filter
Filter stream items with provided predicate.- Parameters:
predicate- predicate to filter stream with- Returns:
- Multi
-
first
- Returns:
- Single
-
flatMap
default <U> Multi<U> flatMap(Function<? super T, ? extends Flow.Publisher<? extends U>> publisherMapper) Transform item with supplied function and flatten resultingFlow.Publisherto downstream.- Specified by:
flatMapin interfaceSubscribable<T>- Type Parameters:
U- output item type- Parameters:
publisherMapper-Functionreceiving item as parameter and returningFlow.Publisher- Returns:
- Multi
-
flatMap
default <U> Multi<U> flatMap(Function<? super T, ? extends Flow.Publisher<? extends U>> mapper, long maxConcurrency, boolean delayErrors, long prefetch) Transform item with supplied function and flatten resultingFlow.Publisherto downstream while limiting the maximum number of concurrent innerFlow.Publishers and their in-flight item count, optionally aggregating and delaying all errors until all sources terminate.- Type Parameters:
U- output item type- Parameters:
mapper-Functionreceiving item as parameter and returningFlow.PublishermaxConcurrency- the maximum number of inner sources to rundelayErrors- if true, any error from the main and inner sources are aggregated and delayed until all of them terminateprefetch- the number of items to request upfront from the inner sources, then request 75% more after 75% has been delivered- Returns:
- Multi
-
flatMapCompletionStage
default <U> Multi<U> flatMapCompletionStage(Function<? super T, ? extends CompletionStage<? extends U>> mapper) Transform item with supplied function and flatten resultingCompletionStageresults to downstream. As reactive streams forbids null values, error signal withNullPointerExceptionis sent to downstream when CompletionStage result is null.- Type Parameters:
U- output item type- Parameters:
mapper-Functionreceiving item as parameter and returningCompletionStage- Returns:
- Multi
- Throws:
NullPointerException- if mapper isnull
-
flatMapIterable
default <U> Multi<U> flatMapIterable(Function<? super T, ? extends Iterable<? extends U>> iterableMapper) Transform item with supplied function and flatten resultingIterableto downstream.- Specified by:
flatMapIterablein interfaceSubscribable<T>- Type Parameters:
U- output item type- Parameters:
iterableMapper-Functionreceiving item as parameter and returningIterable- Returns:
- Multi
-
flatMapIterable
default <U> Multi<U> flatMapIterable(Function<? super T, ? extends Iterable<? extends U>> iterableMapper, int prefetch) Transform item with supplied function and flatten resultingIterableto downstream. -
flatMapOptional
Transform item with supplied function and flatten resultingOptionalto downstream as one item if present or nothing if empty. -
limit
Limit stream to allow only specified number of items to pass.- Parameters:
limit- with expected number of items to be produced- Returns:
- Multi
-
map
- Specified by:
mapin interfaceSubscribable<T>- Type Parameters:
U- mapped item type- Parameters:
mapper- mapper- Returns:
- Multi
- Throws:
NullPointerException- if mapper isnull
-
observeOn
Re-emit the upstream's signals to the downstream on the given executor's thread using a default buffer size of 32 and errors skipping ahead of items.- Specified by:
observeOnin interfaceSubscribable<T>- Parameters:
executor- the executor to signal the downstream from.- Returns:
- Multi
- Throws:
NullPointerException- ifexecutorisnull- See Also:
-
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.bufferSize- the number of items to prefetch and buffer at a timedelayError- iftrue, errors are emitted after items, iffalse, errors may cut ahead of items during emission- Returns:
- Multi
- Throws:
NullPointerException- ifexecutorisnull
-
onCancel
Executes givenRunnablewhen a cancel signal is received.- Specified by:
onCancelin interfaceSubscribable<T>- Parameters:
onCancel-Runnableto be executed.- Returns:
- Multi
-
onComplete
Executes givenRunnablewhen onComplete signal is received.- Specified by:
onCompletein interfaceSubscribable<T>- Parameters:
onComplete-Runnableto be executed.- Returns:
- Multi
-
onError
Executes givenRunnablewhen onError signal is received.- Specified by:
onErrorin interfaceSubscribable<T>- Parameters:
onErrorConsumer-Consumerto be executed.- Returns:
- Multi
-
onErrorResume
Functionproviding one item to be submitted as onNext in case of onError signal is received.- Specified by:
onErrorResumein interfaceSubscribable<T>- Parameters:
onError- Function receivingThrowableas argument and producing one item to resume stream with.- Returns:
- Multi
-
onErrorResumeWith
default Multi<T> onErrorResumeWith(Function<? super Throwable, ? extends Flow.Publisher<? extends T>> onError) Resume stream from supplied publisher if onError signal is intercepted.- Specified by:
onErrorResumeWithin interfaceSubscribable<T>- Parameters:
onError- supplier of new stream publisher- Returns:
- Multi
-
onCompleteResume
Resume stream from single item if onComplete signal is intercepted. Effectively do anappendto the stream.- Specified by:
onCompleteResumein interfaceSubscribable<T>- Parameters:
item- one item to resume stream with- Returns:
- Multi
-
onCompleteResumeWith
Resume stream from supplied publisher if onComplete signal is intercepted.- Specified by:
onCompleteResumeWithin interfaceSubscribable<T>- Parameters:
publisher- new stream publisher- Returns:
- Multi
-
onTerminate
Executes givenRunnablewhen any of signals onComplete, onCancel or onError is received.- Specified by:
onTerminatein interfaceSubscribable<T>- Parameters:
onTerminate-Runnableto be executed.- Returns:
- Multi
-
ifEmpty
Executes givenRunnablewhen stream is finished without value(empty stream).- Parameters:
ifEmpty-Runnableto be executed.- Returns:
- Multi
-
peek
Invoke provided consumer for every item in stream.- Specified by:
peekin interfaceSubscribable<T>- Parameters:
consumer- consumer to be invoked- Returns:
- Multi
-
log
Log all signalsonSubscribe,onNext,onError,onComplete,cancelandrequestcoming to and from preceding operator.- Returns:
- Multi
-
log
Log all signalsonSubscribe,onNext,onError,onComplete,cancelandrequestcoming to and from preceding operator.- Parameters:
level- a logging level value- Returns:
- Multi
-
log
Log all signalsonSubscribe,onNext,onError,onComplete,cancelandrequestcoming to and from preceding operator.- Parameters:
level- a logging level valueloggerName- custom logger name- Returns:
- Multi
-
log
Log all signalsonSubscribe,onNext,onError,onComplete,cancelandrequestcoming to and from preceding operator.Enabled trace option has a negative impact on performance and should NOT be used in production.
- Parameters:
level- a logging level valuetrace- if true position of operator is looked up from stack and logged- Returns:
- Multi
-
reduce
Combine subsequent items via a callback function and emit the final value result as a Single.If the upstream is empty, the resulting Single is also empty. If the upstream contains only one item, the reducer function is not invoked and the resulting Single will have only that single item.
- Parameters:
reducer- the function called with the first value or the previous result, the current upstream value and should return a new value- Returns:
- Single
-
reduce
Combine every upstream item with an accumulator value to produce a new accumulator value and emit the final accumulator value as a Single.- Type Parameters:
R- the accumulator and result type- Parameters:
supplier- the function to return the initial accumulator value for each incoming Subscriberreducer- the function that receives the current accumulator value, the current upstream value and should return a new accumulator value- Returns:
- Single
-
retry
Retry a failing upstream at most the given number of times before giving up.- Specified by:
retryin interfaceSubscribable<T>- Parameters:
count- the number of times to retry; 0 means no retry at all- Returns:
- Multi
- Throws:
IllegalArgumentException- ifcountis negative- See Also:
-
retry
Retry a failing upstream if the predicate returns true.- Specified by:
retryin interfaceSubscribable<T>- 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:
- Multi
- Throws:
NullPointerException- ifpredicateisnull- See Also:
-
retryWhen
default <U> Multi<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 Multi is completed. If the publisher signals an error, the repetition stops and this Multi will signal this error.
- Specified by:
retryWhenin interfaceSubscribable<T>- 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 Multi or signal an error to have this Multi emit that error as well.- Returns:
- Multi
- Throws:
NullPointerException- ifwhenFunctionisnull
-
skip
Skip first n items, all the others are emitted.- Parameters:
skip- number of items to be skipped- Returns:
- Multi
-
switchIfEmpty
Switch to the other publisher if the upstream is empty.- Parameters:
other- the publisher to switch to if the upstream is empty.- Returns:
- Multi
- Throws:
NullPointerException- ifotherisnull
-
takeUntil
Relay upstream items until the other source signals an item or completes.- Specified by:
takeUntilin interfaceSubscribable<T>- Type Parameters:
U- the element type of the other sequence- Parameters:
other- the other sequence to signal the end of the main sequence- Returns:
- Multi
- Throws:
NullPointerException- ifotherisnull
-
takeWhile
Take the longest prefix of elements from this stream that satisfy the given predicate. As long as predicate returns true, items from upstream are sent to downstream, when predicate returns false stream is completed.- Parameters:
predicate- predicate to filter stream with- Returns:
- Multi
-
timeout
Signals aTimeoutExceptionif the upstream doesn't signal the next item, error or completion within the specified time.- Specified by:
timeoutin interfaceSubscribable<T>- 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:
- Multi
- Throws:
NullPointerException- ifunitorexecutorisnull
-
timeout
default Multi<T> timeout(long timeout, TimeUnit unit, ScheduledExecutorService executor, Flow.Publisher<T> fallback) Switches to a fallback single 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 signalfallback- the Single to switch to if the upstream doesn't signal in time- Returns:
- Multi
- Throws:
NullPointerException- ifunit,executororfallbackisnull
-
to
Apply the givenconverterfunction to the currentMultiinstance and return the value returned by this function.Note that the
converterfunction is executed upon calling this method immediately and not when the resulting sequence gets subscribed to.- Type Parameters:
U- the output type- Parameters:
converter- the function that receives the currentMultiinstance and should return a value to be returned by the method- Returns:
- the value returned by the function
- Throws:
NullPointerException- ifconverterisnull
-
forEach
Terminal stage, invokes provided consumer for every item in the stream with no backpressure.- Parameters:
consumer- consumer to be invoked for each item- Returns:
- Single completed when the stream terminates
-
forEachCompletionStage
Terminal stage, invokes provided consumer for every item in the stream with strict backpressure. Items are requested 1 by 1 with no prefetch always waiting for each completion stage to complete before requesting another item.- Parameters:
function- invoked for each item returning completion stage to signal asynchronous completion- Returns:
- Single completed when the stream terminates
-
ignoreElements
Terminal stage, ignore all items and complete returnedSingle<Void>successfully or exceptionally.- Returns:
- Single completed when the stream terminates
-
create(io.helidon.common.reactive.Single)instead