Why ReadSide default implementations store event handlers in a Map with Class as the key?

Hi!, I would like to know (and underestand) the rationale behind this. I see that this could be beneficial for simplicity, but it doesn’t help if you want to go a little further, but maybe there is a theoretical foundation for it.

In my case, I would like to have:

sealed trait Evt
case class E1

sealed trait EvtRS extends Evt
case class E2 extends EvtRS
case class E3 extends EvtRS

as a way to express that from all my events, only E2 and E3 should be handled in the read side.

Then I would like to write:

builder.setEventHandler[EvtRS](...)

and the pattern matching will tell me if I forgot to handle any _ <: EvtRS.

Thanks,

Alden

1 Like