Currently I'm playing around with Backbone/Marionette (though question is more general), and I have a lot of code that "sending messages" all over the application. Just as an example, something like this:
vent.on("search:start", function() {...});
vent.trigger("search:start");
But I don't have any good way to track down (document) which messages/calls are available within an application.
So my question is: What is a good way to document this (sub/pub)?
I would assume (though I didn't find one) there might be a tool that will allow you to add comments (Javadoc style), and it will generate something more or less reasonable out of it.
Dead-letter topic Maximum number of delivery attempts: A numeric value that signifies the number of delivery attempts that Pub/Sub makes for a specific message. If the subscriber client cannot acknowledge the message within the configured number of delivery attempts, the message is forwarded to a dead-letter topic.
My recommendation would be to have one big signals.eventConstants. It's an object that's sole purpose is to hold a list of strings that get placed into the subscriber or publisher as the thing you're publishing or subscribing to.
So instead of doing
vent.on("search:start", function() {...});
vent.trigger("search:start");
You would do
vent.on(signals.eventConstants.searchStart, function() {...});
vent.trigger(signals.eventConstants.searchStart);
Then you have one central place where you can check for all your publish/subscription broadcast topics, AND if you want to change the name of them, or add more later, you have one place to check so you don't create identical broadcasts.
Inside of signals.eventConstants you could also document the purpose of each signal with comments.
So you'd have something like
//This broadcast will fire when a search is started
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With