I am working with Reddis but this could apply to any PubSub implementation. Essentially we are trying to implement an event system using Reddis's PubSub capabilities.
As an example UserA creates a WidgetX so we would publish a
"WidgetX.Create" event. There could be multiple subscribers that subscriber to this event. One would create a record in a user log table, another might blast emails out to other users that care about WidgetX creations. There could also be a
"WidgetY.Create" event that would, probably have some similar subscribers but could also have some unique ones as well.
All in all there could potentially be 100's of different combinations of events, each of them publishing their own data. I'm not to worried about how to handle the publishing of the event because that can be as simple as
void Publish(string eventName, object payload). I'm more worried about being able to easily subscribe to an event. When I say easy, I mean I don't have to go looking for an event name and what its payload is by digging through the code to see where this event is being published. It would be nice if there was a way to know this by subscribing to the event, or a way to make it painfully obvious?
Is it worth it to maintain a bunch of delegates that accept a specific payload. Maybe a class for each subscription type that has a
Publish accepts a specific payload and
Subscribe accepts a function that takes that payload as a parameter. Or maybe just find a way to maintain the Subscription strings, like passing enums to a function that pops out a string, so the subscriber can be completely generic and just ask to wait for the event and accept whatever the payload may be.