Skip to content

When to use a Multi or Uni<Collection>? #681

Answered by cescoffier
kjq asked this question in Q&A
Discussion options

You must be logged in to vote

It's a great question! The answer is "it depends".

It depends on whether your remote call returns a single object or a (potentially unbounded) sequence of objects.

The simple case is when you receive a single object (T). In this case, use Uni<T>.
If you receive a sequence, It depends if that sequence is returned in a single batch or multiple. In the first case, it's better to use Uni<List<T>>. It would avoid the ceremony to create a Multi from something already in memory. If, however, it's a stream (bounded or not), in this case, it's better to use Multi<T>, as you would be able to start processing the first `T's while the next ones are still in transit.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@mklueh
Comment options

@cescoffier
Comment options

Answer selected by jponge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants