Has anyone here experimented with adding types to the event aggregator events?
I was thinking of making the pub/sub system more transparent by declaring the different messages and the data that they can/must include with the messages, but I dont know if this would even end up being beneficial in the long run or just unnecessary overhead.
One idea I had was using enums: Message.SessionCreated, Message.SessionExpired etc, but then I was thinking of how to also declare the data that might accompany these messages…
Pretty much like your example, yeah! I was thinking that the channel could be perhaps a static enum value of a class while the object of the class contains the data we might want to
send.
Something like ea.publish(SessionCreatedEvent.Channel, new SessionCreatedEvent(params))
But then it got me thinking that this all depends on the style of pub/sub that you implement, as its possible to do it atleast 2 different ways:
Generic channels, where the additional data has a format and the subscribers filter out the messages based on the additional data
Specific channels, where the subscribers know that when something is published it is meant for them
With the ea supporting subscribeOnce, it seemed to me that 2. is being used more.
(For now, I dont think I am gonna create a complicated system when I only need to subscribe to a few events.)