- 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 givencomposer
function to the currentMulti
instance and return aMulti
wrapping the returnedFlow.Publisher
of 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.Publisher
s by relaying items in order, non-overlappingly, one after the other finishes.static <T> Multi
<T> static <T> Multi
<T> Create aMulti
instance 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 aMulti
instance 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 aMulti
instance that completes immediately.static <T> Multi
<T> Create aMulti
instance 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.Publisher
to 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.Publisher
to downstream while limiting the maximum number of concurrent innerFlow.Publisher
s 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 resultingCompletionStage
results to downstream.default <U> Multi
<U> flatMapIterable
(Function<? super T, ? extends Iterable<? extends U>> iterableMapper) Transform item with supplied function and flatten resultingIterable
to downstream.default <U> Multi
<U> flatMapIterable
(Function<? super T, ? extends Iterable<? extends U>> iterableMapper, int prefetch) Transform item with supplied function and flatten resultingIterable
to downstream.default <U> Multi
<U> flatMapOptional
(Function<? super T, Optional<? extends U>> mapper) Transform item with supplied function and flatten resultingOptional
to 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 givenRunnable
when 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 aMulti
instance that publishes the given items to a single subscriber.static <T> Multi
<T> just
(T... items) Create aMulti
instance 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
,cancel
andrequest
coming to and from preceding operator.Log all signalsonSubscribe
,onNext
,onError
,onComplete
,cancel
andrequest
coming to and from preceding operator.Log all signalsonSubscribe
,onNext
,onError
,onComplete
,cancel
andrequest
coming to and from preceding operator.Log all signalsonSubscribe
,onNext
,onError
,onComplete
,cancel
andrequest
coming to and from preceding operator.default <U> Multi
<U> static <T> Multi
<T> never()
Get aMulti
instance 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 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.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 aMulti
that 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 aTimeoutException
if 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> U
Apply the givenconverter
function to the currentMulti
instance and return the value returned by this function.Methods inherited from interface java.util.concurrent.Flow.Publisher
subscribe
Methods 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.Publisher
s 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
- ifsupplier
isnull
-
empty
Get aMulti
instance that completes immediately.- Type Parameters:
T
- item type- Returns:
- Multi
-
error
Create aMulti
instance 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
NullPointerException
signal.- 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 aMulti
instance 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 aMulti
instance 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
- sourceSingle
publisher- Returns:
- Multi
- Throws:
NullPointerException
- if source isnull
-
from
Deprecated.usecreate(java.util.stream.Stream)
insteadCreate aMulti
instance that publishes the givenStream
.Note that Streams can be only consumed once, therefore, the returned Multi will signal
IllegalStateException
if 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 theStream
into anIterable
viaBaseStream.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
- ifstream
isnull
-
create
Wrap a CompletionStage into a Multi and signal its outcome non-blockingly.A null result from the CompletionStage will yield a
NullPointerException
signal.- 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 aMulti
instance that publishes the given iterable.- Type Parameters:
T
- item type- Parameters:
iterable
- iterable to publish- Returns:
- Multi
- Throws:
NullPointerException
- if iterable isnull
-
create
Create aMulti
instance 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
- sourceSingle
publisher- Returns:
- Multi
- Throws:
NullPointerException
- if source isnull
-
create
Create aMulti
instance that publishes the givenStream
.Note that Streams can be only consumed once, therefore, the returned Multi will signal
IllegalStateException
if 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 theStream
into anIterable
viaBaseStream.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
- ifstream
isnull
-
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
- ifunit
orexecutor
isnull
-
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
- ifunit
orexecutor
isnull
-
just
Create aMulti
instance that publishes the given items to a single subscriber.- Type Parameters:
T
- item type- Parameters:
items
- items to publish- Returns:
- Multi
- Throws:
NullPointerException
- ifitems
isnull
-
just
Create aMulti
instance that publishes the given items to a single subscriber.- Type Parameters:
T
- item type- Parameters:
items
- items to publish- Returns:
- Multi
- Throws:
NullPointerException
- ifitems
isnull
-
never
Get aMulti
instance 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
- ifcount
is 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
- ifcount
is negative
-
singleton
Create aMulti
that 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
- ifitem
isnull
-
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
- ifunit
orexecutor
isnull
-
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 thisMulti
into a collection provided via aSupplier
and mutated by aBiConsumer
callback.- Type Parameters:
U
- the type of the collection and result- Parameters:
collectionSupplier
- theSupplier
that is called for each incomingFlow.Subscriber
to create a fresh collection to collect items intoaccumulator
- theBiConsumer
that receives the collection and the current item to put in- Returns:
- Single
- Throws:
NullPointerException
- ifcollectionSupplier
orcombiner
isnull
-
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
- ifcollector
isnull
-
compose
default <U> Multi<U> compose(Function<? super Multi<T>, ? extends Flow.Publisher<? extends U>> composer) Apply the givencomposer
function to the currentMulti
instance and return aMulti
wrapping the returnedFlow.Publisher
of this function.Note that the
composer
function 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 currentMulti
instance and should return aFlow.Publisher
to be wrapped into aMultie
to be returned by the method- Returns:
- Multi
- Throws:
NullPointerException
- ifcomposer
isnull
-
defaultIfEmpty
Signals the default item if the upstream is empty.- Specified by:
defaultIfEmpty
in interfaceSubscribable<T>
- Parameters:
defaultItem
- the item to signal if the upstream is empty- Returns:
- Multi
- Throws:
NullPointerException
- ifdefaultItem
isnull
-
defaultIfEmpty
Signals the default item supplied by specified supplier if the upstream is empty.- Specified by:
defaultIfEmpty
in interfaceSubscribable<T>
- Parameters:
supplier
- of the default value- Returns:
- Multi
- Throws:
NullPointerException
- ifsupplier
isnull
-
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.Publisher
to downstream.- Specified by:
flatMap
in interfaceSubscribable<T>
- Type Parameters:
U
- output item type- Parameters:
publisherMapper
-Function
receiving 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.Publisher
to downstream while limiting the maximum number of concurrent innerFlow.Publisher
s and their in-flight item count, optionally aggregating and delaying all errors until all sources terminate.- Type Parameters:
U
- output item type- Parameters:
mapper
-Function
receiving item as parameter and returningFlow.Publisher
maxConcurrency
- 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 resultingCompletionStage
results to downstream. As reactive streams forbids null values, error signal withNullPointerException
is sent to downstream when CompletionStage result is null.- Type Parameters:
U
- output item type- Parameters:
mapper
-Function
receiving 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 resultingIterable
to downstream.- Specified by:
flatMapIterable
in interfaceSubscribable<T>
- Type Parameters:
U
- output item type- Parameters:
iterableMapper
-Function
receiving 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 resultingIterable
to downstream. -
flatMapOptional
Transform item with supplied function and flatten resultingOptional
to 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:
map
in 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:
observeOn
in interfaceSubscribable<T>
- Parameters:
executor
- the executor to signal the downstream from.- Returns:
- Multi
- Throws:
NullPointerException
- ifexecutor
isnull
- 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
- ifexecutor
isnull
-
onCancel
Executes givenRunnable
when a cancel signal is received.- Specified by:
onCancel
in interfaceSubscribable<T>
- Parameters:
onCancel
-Runnable
to be executed.- Returns:
- Multi
-
onComplete
Executes givenRunnable
when onComplete signal is received.- Specified by:
onComplete
in interfaceSubscribable<T>
- Parameters:
onComplete
-Runnable
to be executed.- Returns:
- Multi
-
onError
Executes givenRunnable
when onError signal is received.- Specified by:
onError
in interfaceSubscribable<T>
- Parameters:
onErrorConsumer
-Consumer
to be executed.- Returns:
- Multi
-
onErrorResume
Function
providing one item to be submitted as onNext in case of onError signal is received.- Specified by:
onErrorResume
in interfaceSubscribable<T>
- Parameters:
onError
- Function receivingThrowable
as 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:
onErrorResumeWith
in interfaceSubscribable<T>
- Parameters:
onError
- supplier of new stream publisher- Returns:
- Multi
-
onCompleteResume
Resume stream from single item if onComplete signal is intercepted. Effectively do anappend
to the stream.- Specified by:
onCompleteResume
in 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:
onCompleteResumeWith
in interfaceSubscribable<T>
- Parameters:
publisher
- new stream publisher- Returns:
- Multi
-
onTerminate
Executes givenRunnable
when any of signals onComplete, onCancel or onError is received.- Specified by:
onTerminate
in interfaceSubscribable<T>
- Parameters:
onTerminate
-Runnable
to be executed.- Returns:
- Multi
-
ifEmpty
Executes givenRunnable
when stream is finished without value(empty stream).- Parameters:
ifEmpty
-Runnable
to be executed.- Returns:
- Multi
-
peek
Invoke provided consumer for every item in stream.- Specified by:
peek
in interfaceSubscribable<T>
- Parameters:
consumer
- consumer to be invoked- Returns:
- Multi
-
log
Log all signalsonSubscribe
,onNext
,onError
,onComplete
,cancel
andrequest
coming to and from preceding operator.- Returns:
- Multi
-
log
Log all signalsonSubscribe
,onNext
,onError
,onComplete
,cancel
andrequest
coming to and from preceding operator.- Parameters:
level
- a logging level value- Returns:
- Multi
-
log
Log all signalsonSubscribe
,onNext
,onError
,onComplete
,cancel
andrequest
coming to and from preceding operator.- Parameters:
level
- a logging level valueloggerName
- custom logger name- Returns:
- Multi
-
log
Log all signalsonSubscribe
,onNext
,onError
,onComplete
,cancel
andrequest
coming 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:
retry
in interfaceSubscribable<T>
- Parameters:
count
- the number of times to retry; 0 means no retry at all- Returns:
- Multi
- Throws:
IllegalArgumentException
- ifcount
is negative- See Also:
-
retry
Retry a failing upstream if the predicate returns true.- Specified by:
retry
in interfaceSubscribable<T>
- 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:
- Multi
- Throws:
NullPointerException
- ifpredicate
isnull
- 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:
retryWhen
in interfaceSubscribable<T>
- 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 Multi or signal an error to have this Multi emit that error as well.- Returns:
- Multi
- Throws:
NullPointerException
- ifwhenFunction
isnull
-
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
- ifother
isnull
-
takeUntil
Relay upstream items until the other source signals an item or completes.- Specified by:
takeUntil
in 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
- ifother
isnull
-
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 aTimeoutException
if the upstream doesn't signal the next item, error or completion within the specified time.- Specified by:
timeout
in 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
- ifunit
orexecutor
isnull
-
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
,executor
orfallback
isnull
-
to
Apply the givenconverter
function to the currentMulti
instance and return the value returned by this function.Note that the
converter
function 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 currentMulti
instance and should return a value to be returned by the method- Returns:
- the value returned by the function
- Throws:
NullPointerException
- ifconverter
isnull
-
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