SpineEventEngine / core-java

The Java implementation of the framework core
https://spine.io
Apache License 2.0
36 stars 12 forks source link

Allow returning Optional<Tuple> from @React handlers #1218

Open yuri-sergiichuk opened 4 years ago

yuri-sergiichuk commented 4 years ago

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.

alexander-yevsyukov commented 4 years ago

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.

yuri-sergiichuk commented 4 years ago

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.