Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a good way to document sub/pub? [closed]

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.

like image 998
Dmitry F Avatar asked Apr 05 '13 03:04

Dmitry F


People also ask

What is Pubsub dead letter?

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.


1 Answers

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
like image 58
Jazzepi Avatar answered Sep 19 '22 20:09

Jazzepi