ftlabs/fruitmachine

Should nested events be prefixed with the module name?

wilsonpage opened this issue · 2 comments

Bubbling events are now supported in 0.3.0, but how should we listen to them.

view.on('buttonclick', function(){});

The problem with the above is that there could easily be serveral modules in the view that emit a button click event. This makes it difficult to listen to the correct one. We can either rely on the module authors to make non conflicting event names, or we could prefix event names when emitted on a parent view.

view.on('pickle:buttonclick', function(){});

When listening directly, the prefix would not be required.

pickle.on('buttonclick', function(){});

No, this would make our modules less interchangeable.

Suggest we do something similar to delegate:-

view.on('buttonclick', 'pickle', function(){});

Where the 2nd argument is optional and is the module name:-

view.on('buttonclick', function(){});

Would continue to "catch all"...

👍