javascript - What is a good way to document sub/pub? -
currently i'm playing around backbone/marionette (though question more general), , have lot of code "sending messages" on application. example, this:
vent.on("search:start", function() {...}); vent.trigger("search:start");
but don't have way track down (document) messages/calls available within application.
so question is: way document (sub/pub)?
i assume (though didn't find one) there might tool allow add comments (javadoc style), , generate more or less reasonable out of it.
my recommendation have 1 big signals.eventconstants. it's object that's sole purpose hold list of strings placed subscriber or publisher thing you're publishing or subscribing to.
so instead of doing
vent.on("search:start", function() {...}); vent.trigger("search:start");
you do
vent.on(signals.eventconstants.searchstart, function() {...}); vent.trigger(signals.eventconstants.searchstart);
then have 1 central place can check publish/subscription broadcast topics, , if want change name of them, or add more later, have 1 place check don't create identical broadcasts.
inside of signals.eventconstants document purpose of each signal comments.
so you'd have like
//this broadcast fire when search started
Comments
Post a Comment