Question

What name spacing convention do ppl use for events throughout their application.

For example:

App.vent.trigger("list:search:clicked", e);

or

App.vent.trigger("list:clicked", e);

where 'list' is my controller, 'search' would be a my module and 'clicked' is the action. The first 'list:search:clicked' seems to make alot of sense but is that the order ppl are going in. Also this doesn't say anything about what actual element was clicked or what method has been invoked. Appreciate the input thanks.

Was it helpful?

Solution

If you want to be consistent with how Marionette appends qualifiers when bubbling up events, it would be ordered in increasingly specific scope like module:controller:action.

Personally, we always maintain a JS file that maps event names to properties on an EventNames object so that dev tools can catch typos. These variable names can follow a less rigid naming convention of "make sense when read as English" and the actual string values then cease to matter

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top