Uni and Multi#
Mutiny defines two reactive types:
Multi- represents streams of 0..* items (potentially unbounded)Uni- represents streams receiving either an item or a failure
Tip
The Mutiny name comes from the contraction of Multi and Uni names
Both Uni and Multi are asynchronous types.
They receive and fire events at any time.
You may wonder why we make the distinction between Uni and Multi.
Conceptually, a Uni is a Multi, right?
In practice, you don’t use Unis and Multis the same way.
The use cases and operations are different.
Unidoes not need the complete ceremony presented above as the request does not make sense.- The
subscribeevent expresses the interest and triggers the computation, no need for an additional request. Unican handle items having anullvalue (and has specific methods to handle this case).Multidoes not allow it (because the Reactive Streams specification forbids it).- Having a
UniimplementingPublisherwould be a bit like havingOptionalimplementingIterable.
In other words, Uni:
- can receive at most 1
itemevent, or afailureevent - cannot receive a
completionevent (nullin the case of 0 items) - cannot receive a
requestevent
The following snippet shows how you can use Uni and Multi: