Like my title says, I do see that Marionette Module is now deprecated and we should AMD modules instead using requirejs. That is fine and everything but the modules had a great purpose in handling initializers and the before:start and start events. It allowed me to setup my regions, views, and collections with ease. What is the alternative now for handling this?
Below is an example of code I would use:
define(['core', './views/mainView'], function(core, mainView) {
var app = core.app;
app.start();
return core.app.module('Home Page Module', function(Module) {
Module.addInitializer(function() {
this.region = new core.Marionette.Region({
el: '#page-container'
});
this.collection = [];
});
Module.on('start', function() {
this.view = new mainView({
collection: this.collection
});
this.region.show(this.view);
});
});
});
I don't have the answer, but Derick Bailey, creator of Marionette, has.
The problem with no sub-applications to start / stop has not yet presented itself in my apps. I don’t need that right now. I know I will need it, though, and when I do run in to that requirement again, I’ll find another solution for it. There’s a good chance I’ll build an add-on for Marionette that specifically works with this new setup, in order to provide the functionality I want.
found here : http://derickbailey.com/2014/06/10/browserify-my-new-choice-for-modules-in-a-browser-backbone-app/
The quote is a little outdated now (one years old), but consider that the feature was deprecated anyway, without any replacement proposal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With