-
public <O> Multi<O> transformToUniAndConcatenate(Function<? super T, Uni<? extends O>> mapper) {
return this.transformToUni(mapper).concatenate();
}
public <O> Multi<O> transformToUniAndMerge(Function<? super T, Uni<? extends O>> mapper) {
return this.transformToUni(mapper).merge();
} According to the tutorial : Multi<String> concat = multi
.onItem().transformToUniAndConcatenate(name -> invokeRemoteGreetingService(name)); If the initial items of Multi are ["a", "b"], after the above code, does it become ["Hello a", "Hello b"] ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is (mostly) for performing asynchronous operations on items, whereas A The resulting See https://smallrye.io/smallrye-mutiny/getting-started/transforming-items-async |
Beta Was this translation helpful? Give feedback.
This is (mostly) for performing asynchronous operations on items, whereas
transform
performs synchronous operations.A
Uni
is a good abstraction for an asynchronous operation like doing a database insert or posting to a message queue.This is why the "mapper" returns a
Uni
, meaning "take this item and perform some operation that will eventually provide a result".The resulting
Multi
collects the result for eachUni
, the only difference is the order. Concatenation preserves the originalMulti
order, while merging pushes the results as soon as eachUni
completes.See https://smallrye.io/smallrye-mutiny/getting-started/transforming-items-async