-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionProduces a newMultiinvoking the given @{code action} when anitemevent is received.Produces a newMultiinvoking the given @{code action} when anitemevent is received, but ignoring it in the callback.<O> Multi<O> Produces anMultiemitting the item events based on the upstream events but casted to the target class.<O> Multi<O> disjoint()Takes the items from the upstreamMultithat are eitherPublisher<O>,O[],Iterable<O>orMulti<O>and disjoint the items to obtain aMulti<O>.gather()Gather each item into an accumulator, and emit new items based on an extractor function.<ACC,O> Multi <O> Gather each item into an accumulator, and emit new items based on an extractor function.ignore()Ignores the passed items.Ignores the passed items.Produces a newMultiinvoking the given callback when anitemevent is fired by the upstream.Produces a newMultiinvoking the given callback when anitemevent is fired by the upstream.scan(BinaryOperator<T> accumulator) <S> Multi<S> scan(Supplier<S> initialStateProducer, BiFunction<S, ? super T, S> accumulator) <R> Multi<R> <O> Multi<O> transformToIterable(Function<? super T, ? extends Iterable<O>> mapper) On each item received from the upstream, call the given mapper.<O> MultiFlatten<T, O> transformToMulti(Function<? super T, ? extends Flow.Publisher<? extends O>> mapper) On each item received from upstream, invoke the given mapper.<O> Multi<O> transformToMultiAndConcatenate(Function<? super T, ? extends Flow.Publisher<? extends O>> mapper) For each items emitted by the upstream, the givenmapperis invoked.<O> Multi<O> transformToMultiAndMerge(Function<? super T, ? extends Flow.Publisher<? extends O>> mapper) For each items emitted by the upstream, the givenmapperis invoked.<O> MultiFlatten<T, O> transformToUni(Function<? super T, Uni<? extends O>> mapper) On each item received from upstream, invoke the given mapper.<O> Multi<O> transformToUniAndConcatenate(Function<? super T, Uni<? extends O>> mapper) For each items emitted by the upstream, the givenmapperis invoked.<O> Multi<O> transformToUniAndMerge(Function<? super T, Uni<? extends O>> mapper) For each items emitted by the upstream, the givenmapperis invoked.
-
Constructor Details
-
MultiOnItem
-
-
Method Details
-
transform
Produces a newMultiinvoking the given function for each item emitted by the upstreamMulti.The function receives the received item as parameter, and can transform it. The returned object is sent downstream as
itemevent.- Type Parameters:
R- the type of item produced by the mapper function- Parameters:
mapper- the mapper function, must not benull- Returns:
- the new
Multi
-
invoke
Produces a newMultiinvoking the given callback when anitemevent is fired by the upstream. Note that the received item cannot benull.If the callback throws an exception, this exception is propagated to the downstream as failure. No more items will be consumed.
- Parameters:
callback- the callback, must not benull- Returns:
- the new
Multi
-
invoke
Produces a newMultiinvoking the given callback when anitemevent is fired by the upstream.If the callback throws an exception, this exception is propagated to the downstream as failure. No more items will be consumed.
- Parameters:
callback- the callback, must not benull- Returns:
- the new
Multi
-
call
Produces a newMultiinvoking the given @{code action} when anitemevent is received. Note that the received item cannot benull.Unlike
invoke(Consumer), the passed function returns aUni. When the producedUnisends its result, the result is discarded, and the originalitemis forwarded downstream. If the producedUnifails, the failure is propagated downstream.If the asynchronous action throws an exception, this exception is propagated downstream.
This method preserves the order of the items, meaning that the downstream received the items in the same order as the upstream has emitted them.
-
call
Produces a newMultiinvoking the given @{code action} when anitemevent is received, but ignoring it in the callback.Unlike
invoke(Consumer), the passed function returns aUni. When the producedUnisends its result, the result is discarded, and the originalitemis forwarded downstream. If the producedUnifails, the failure is propagated downstream.If the asynchronous action throws an exception, this exception is propagated downstream.
This method preserves the order of the items, meaning that the downstream received the items in the same order as the upstream has emitted them.
-
disjoint
Takes the items from the upstreamMultithat are eitherPublisher<O>,O[],Iterable<O>orMulti<O>and disjoint the items to obtain aMulti<O>.For example,
Multi<[A, B, C], [D, E, F]is transformed intoMulti<A, B, C, D, E, F>.If the items from upstream are not instances of
Iterable,Flow.Publisheror array, anIllegalArgumentExceptionis propagated downstream.- Type Parameters:
O- the type items contained in the upstream's items.- Returns:
- the resulting multi
-
transformToMulti
@CheckReturnValue public <O> MultiFlatten<T,O> transformToMulti(Function<? super T, ? extends Flow.Publisher<? extends O>> mapper) On each item received from upstream, invoke the given mapper. This mapper return aFlow.Publisheror aMulti. The return object lets you configure the flattening process, i.e. how the items produced by the returnedPublishers or Multisare propagated to the downstream.- Type Parameters:
O- the type of item emitted by theMultiproduced by the mapper.- Parameters:
mapper- the mapper, must not benull, must not producenull- Returns:
- the object to configure the flatten behavior.
-
transformToMultiAndConcatenate
@CheckReturnValue public <O> Multi<O> transformToMultiAndConcatenate(Function<? super T, ? extends Flow.Publisher<? extends O>> mapper) For each items emitted by the upstream, the givenmapperis invoked. Thismapperreturns aFlow.Publisher. The events emitted by the returnedFlow.Publisherare propagated downstream using aconcatenation, meaning that it does not interleaved the items produced by the differentPublishers.For example, let's imagine an upstream multi {a, b, c} and a mapper emitting the 3 items with some delays between them. For example a -> {a1, a2, a3}, b -> {b1, b2, b3} and c -> {c1, c2, c3}. Using this method on the multi {a, b c} with that mapper may produce the following multi {a1, a2, a3, b1, b2, b3, c1, c2, c3}. So produced multis are concatenated.
This operation is often called concatMap.
If the mapper throws an exception, the failure is propagated downstream. No more items will be emitted. If one of the produced
Flow.Publisherpropagates a failure, the failure is propagated downstream and no more items will be emitted.- Type Parameters:
O- the type of item emitted by theMultiproduced by the mapper.- Parameters:
mapper- the mapper, must not benull, must not producenull- Returns:
- the resulting multi
-
transformToMultiAndMerge
@CheckReturnValue public <O> Multi<O> transformToMultiAndMerge(Function<? super T, ? extends Flow.Publisher<? extends O>> mapper) For each items emitted by the upstream, the givenmapperis invoked. Thismapperreturns aFlow.Publisher. The events emitted by the returnedFlow.Publisherare propagated using amerge, meaning that it may interleave events produced by the differentPublishers.For example, let's imagine an upstream multi {a, b, c} and a mapper emitting the 3 items with some delays between them. For example a -> {a1, a2, a3}, b -> {b1, b2, b3} and c -> {c1, c2, c3}. Using this method on the multi {a, b c} with that mapper may produce the following multi {a1, b1, a2, c1, b2, c2, a3, b3, c3}. So the items from the produced multis are interleaved and are emitted as soon as they are emitted (respecting the downstream request).
This operation is often called flatMap.
If the mapper throws an exception, the failure is propagated downstream. No more items will be emitted. If one of the produced
Flow.Publisherpropagates a failure, the failure is propagated downstream and no more items will be emitted.- Type Parameters:
O- the type of item emitted by theMultiproduced by the mapper.- Parameters:
mapper- the mapper, must not benull, must not producenull- Returns:
- the resulting multi
-
transformToIterable
@CheckReturnValue public <O> Multi<O> transformToIterable(Function<? super T, ? extends Iterable<O>> mapper) On each item received from the upstream, call the given mapper. The mapper returns anIterable. The items from the returnedIterableare propagated downstream (one by one). AsIterableis a synchronous construct, this method concatenates the items produced by the different returns iterables.- Type Parameters:
O- the type of item contained by theIterableproduced by the mapper.- Parameters:
mapper- the mapper, must not benull, must not producenull- Returns:
- the object to configure the flatten behavior.
-
transformToUni
@CheckReturnValue public <O> MultiFlatten<T,O> transformToUni(Function<? super T, Uni<? extends O>> mapper) On each item received from upstream, invoke the given mapper. This mapper returnUni<T>. The return object lets you configure the flattening process, i.e. how the items produced by the returnedUnisare propagated to the downstream.- Type Parameters:
O- the type of item emitted by theMultiproduced by the mapper.- Parameters:
mapper- the mapper, must not benull, must not producenull- Returns:
- the object to configure the flatten behavior.
-
transformToUniAndConcatenate
@CheckReturnValue public <O> Multi<O> transformToUniAndConcatenate(Function<? super T, Uni<? extends O>> mapper) For each items emitted by the upstream, the givenmapperis invoked. Thismapperreturns aUni. The events emitted by the returnedUniare emitted downstream. Items emitted by the returnedUnisare emitted downstream using aconcatenation, meaning that the returnedMulticontains the items in the same order as the upstream.For example, let's imagine an upstream multi {a, b, c} and a mapper emitting 1 items. This emission may be delayed for various reasons. For example a -> a1 without delay, b -> b1 after some delay and c -> c1 without delay. Using this method on the multi {a, b c} with that mapper would produce the following multi {a1, b1, c1}. Indeed, even if c1 could be emitted before b1, this method preserves the order. So the items from the produced unis are concatenated.
This operation is often called concatMapSingle.
If the mapper throws an exception, the failure is propagated downstream. No more items will be emitted. If one of the produced
Unipropagates a failure, the failure is propagated downstream and no more items will be emitted.- Type Parameters:
O- the type of item emitted by theMultiproduced by the mapper.- Parameters:
mapper- the mapper, must not benull, must not producenull- Returns:
- the resulting multi
-
transformToUniAndMerge
@CheckReturnValue public <O> Multi<O> transformToUniAndMerge(Function<? super T, Uni<? extends O>> mapper) For each items emitted by the upstream, the givenmapperis invoked. Thismapperreturns aUni. The events emitted by the returnedUniare emitted downstream. Items emitted by the returnedUnisare emitted downstream using amerge, meaning that it may interleave events produced by the differentUni.For example, let's imagine an upstream multi {a, b, c} and a mapper emitting 1 items. This emission may be delayed for various reasons. For example a -> a1 without delay, b -> b1 after some delay and c -> c1 without delay. Using this method on the multi {a, b c} with that mapper would produce the following multi {a1, c1, b1}. Indeed, the b1 item is emitted after c1. So the items from the produced unis are interleaved and are emitted as soon as they are emitted (respecting the downstream request).
This operation is often called flatMapSingle.
If the mapper throws an exception, the failure is propagated downstream. No more items will be emitted. If one of the produced
Unipropagates a failure, the failure is propagated downstream and no more items will be emitted.- Type Parameters:
O- the type of item emitted by theMultiproduced by the mapper.- Parameters:
mapper- the mapper, must not benull, must not producenull- Returns:
- the resulting multi
-
ignore
Ignores the passed items. The resultingMultiwill only be notified when the stream completes or fails.- Returns:
- the new multi
-
ignoreAsUni
Ignores the passed items. The resultingUniwill only be completed withnullwhen the stream completes or with a failure if the upstream emits a failure..- Returns:
- the new
Uni
-
castTo
Produces anMultiemitting the item events based on the upstream events but casted to the target class.- Type Parameters:
O- the type of item emitted by the produced uni- Parameters:
target- the target class- Returns:
- the new
Multi
-
scan
@CheckReturnValue public <S> Multi<S> scan(Supplier<S> initialStateProducer, BiFunction<S, ? super T, S> accumulator) Produces aMultithat fires items coming from the reduction of the item emitted by this currentMultiby the passedaccumulatorreduction function. The produced multi emits the intermediate results.Unlike
scan(BinaryOperator), this operator uses the value produced by theinitialStateProduceras first value.- Type Parameters:
S- the type of item emitted by the producedMulti. It's the type returned by theaccumulatoroperation.- Parameters:
initialStateProducer- the producer called to provides the initial value passed to the accumulator operation.accumulator- the reductionBiFunction, the resultingMultiemits the results of this method. The method is called for every item emitted by this Multi.- Returns:
- the produced
Multi
-
scan
Produces aMultithat fires results coming from the reduction of the item emitted by this currentMultiby the passedaccumulatorreduction function. The produced multi emits the intermediate results.Unlike
scan(Supplier, BiFunction), this operator doesn't take an initial value but takes the first item emitted by thisMultias initial value.- Parameters:
accumulator- the reductionBiFunction, the resultingMultiemits the results of this method. The method is called for every item emitted by this Multi.- Returns:
- the produced
Multi
-
failWith
Produces a newMultiinvoking the given function when the currentMultifires an item (only once). The function transforms the received item into a failure that will be fired by the producedMulti. For asynchronous composition, seetransformToUni(Function)}.The upstream subscription is cancelled after the emission of the first item, as a failure is propagated downstream.
- Parameters:
mapper- the mapper function, must not benull, must not returnnull- Returns:
- the new
Multi
-
failWith
Produces a newMultiinvoking the given supplier when the currentUnifires an item. The supplier produce the received item into a failure that will be fired by the producedMulti.The upstream subscription is cancelled after the emission of the first item, as a failure is propagated downstream.
- Parameters:
supplier- the supplier to produce the failure, must not benull, must not producenull- Returns:
- the new
Multi
-
gather
@Experimental("This API is still being designed and may change in the future") @CheckReturnValue public MultiOnItemGather<T> gather()Gather each item into an accumulator, and emit new items based on an extractor function.- Returns:
- a new
MultiOnItemGatherthat lets you configure the gathering of items emitted by the upstream
-
gather
@Experimental("This API is still being designed and may change in the future") @CheckReturnValue public <ACC,O> Multi<O> gather(Gatherer<T, ACC, O> gatherer) Gather each item into an accumulator, and emit new items based on an extractor function.- Returns:
- a new
MultiOnItemGatherthat lets you configure the gathering of items emitted by the upstream
-