I am trying to configure vent / EventAggregator as a separate Require.js module. I am using Marionette 1.0.2 (which I believe is different from previous versions to 1.0.0) with wreqr enabled: this code is from backbone.marionette.js: -
// Event Aggregator // ---------------- // A pub-sub object that can be used to decouple various parts // of an application through event-driven architecture. Wreqr.EventAggregator = (function(Backbone, _){ "use strict"; var EA = function(){}; // Copy the `extend` function used by Backbone classes EA.extend = Backbone.Model.extend; // Copy the basic Backbone.Events on to the event aggregator _.extend(EA.prototype, Backbone.Events); return EA; })(Backbone, _);
When I configure the vent.js module, what should it be? Something like that: -
define(['marionette'],function(Marionette){ return new Marionette.EventAggregator(); })
Also in my config requirement should I explicitly include backbone.wreqr.js or not? Or should only the puppet file be enough (see snippet above)?
For reference: my app.js: -
require.config({ paths : { backbone : 'lib/backbone', underscore : 'lib/underscore', jquery : 'lib/jquery', marionette : 'lib/backbone.marionette', 'backbone.wreqr' : 'lib/backbone.wreqr', text : 'lib/text', templates : '../templates' }, shim : { jquery : { exports : 'jQuery' }, underscore : { exports : '_' }, backbone : { deps : ['jquery', 'underscore'], exports : 'Backbone' }, marionette : { deps : ['jquery', 'underscore', 'backbone'], exports : 'Marionette' }, 'backbone.wreqr' : { deps : ['backbone', 'marionette', 'underscore'], exports : 'Wreqr' } } }) require( ["jquery", "underscore", "backbone", "marionette", "backbone.wreqr", "shell/shellapp" ], function($, _, Backbone, Marionette, Wreqr, ShellApp) { $(function() {
All help is much appreciated!
Thank you very much,
Sam
_______ **** UPDATE
Thanks to Paul, I figured out how to make vent.js. work FYI I did NOT need to import the wreqr file separately in the config. Here is the vent.js code: -
define(['backbone', 'marionette'],function(Backbone, Marionette){ return new Backbone.Wreqr.EventAggregator(); });