core-java icon indicating copy to clipboard operation
core-java copied to clipboard

Allow returning Optional<Tuple> from @React handlers

Open yuri-sergiichuk opened this issue 5 years ago • 2 comments

Currently, from event reactor method we can return:

  1. EventMessage
  2. Optional<EventMessage>
  3. Iterable<EventMessage>
  4. EitherOf<...>

But, to express that we want to return a pair (or triplet, or ...) of events or nothing we have now the following options:

  1. Triplet<EventMessage,EventMessage,Nothing>
  2. Iterable<EventMessage> where iterable is empty when no events are emitted

The best way to express this, from my standpoint, is to have an Optional<Pair<EventMessage, EventMessage>> that is not supported by the framework now.

yuri-sergiichuk avatar Dec 26 '19 15:12 yuri-sergiichuk

Triplet<EventMessage,EventMessage,Nothing>

This does not make much sense. It's a Pair. But your request does make sense. How often do you need such a thing?

Depending on the answer, we'd schedule this.

alexander-yevsyukov avatar Oct 15 '20 17:10 alexander-yevsyukov

Yep, the Triplet<EventMessage,EventMessage,Nothing> is ugly. We've got 3 places in the BKO where we use ImmutableList as a return type with just returning an empty list when smth is optional. We also have a similar approach being used in the Backlog. I believe we'll similar usages in other projects as well.

yuri-sergiichuk avatar Oct 16 '20 06:10 yuri-sergiichuk