5

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.

4

1 回答 1

3

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.

于 2013-09-30T21:04:28.857 回答