Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between relying on Application's event mixin and Application.vent?

Tags:

marionette

What's the point of Application.vent in Marionette? The Application object already extends Backbone.Events, so I can write the following:

window.app = new Backbone.Marionette.Application();
app.on("my:event", function() { console.log(arguments); });
app.trigger("my:event");

More easily than:

window.app = new Backbone.Marionette.Application();
app.vent.on("my:event", function() { console.log(arguments); });
app.vent.trigger("my:event");

I've read the source and I can't tell the difference, but that doesn't mean there isn't one, and I'm half-willing to bet there's a good reason it's done the way it is.

like image 348
Chris Pfohl Avatar asked Oct 21 '22 23:10

Chris Pfohl


1 Answers

While Application.vent's functionality does overlap Application's built-in events, it adds more functionality than just a simple on/trigger event mechanism because it's an instance of Backbone.Wreqr. This adds command events and a request/response mechanism to allow modules to communicate to each other more easily.

It's still just events at the heart of it, but it aims to make inter-module communication a little easier to follow.

like image 125
Craig J Avatar answered Oct 25 '22 18:10

Craig J