I have recently looked at Backbone.Marionette. It mentions the Event Aggregator in a way that seems to be something new.

https://github.com/toekneestuck/edgefonts-preview/blob/master/components/backbone.marionette/docs/marionette.eventaggregator.md

However I don't really see the added benefit to normal events. Doesn't following Code provide you the same?

var dispatcher = _.clone(Backbone.Events)
1

There are 1 answers

0
Simon Boudrias On BEST ANSWER

These are almost exactly the same things. (check the code)

The difference is that EventAggregators is a "class" which can be instantiated (wherea Backbone.Events act more as a mixin).

Being a "class", EventAggregators can be extended.

EventAggregators.extend({ /* your new methods */ });

The difference is really small, but goes a long way in reducing boilerplate necessary to create a event hub with custom prototype methods - and extending them in sub-eventAggregator.