According to the v2.4.1 Marionette documentation controllers are being deprecated:
Warning: deprecated. The Controller object is deprecated. Instead of using the Controller class with the AppRouter, you should specify your callbacks on a plain Javascript object.
I'm confused as to what the best practices are now that they are deprecated? Does this mean that the AppRouter is also being deprecated? If so what are the current patterns being used to develop large scale Marionette applications?
You can probably just use Marionette.Object. It's basically the same as the Controller.
To use a plain JavaScript object with the AppRouter you could do something like this:
var MyController = Marionette.Object.extend({/*...*/});
var AnotherController = Marionette.Object.extend({/*...*/});
var myController = new MyController();
var anotherController = new AnotherController();
var plainJsObject = {
doStuff: myController.doStuff,
doSomethingDifferent: anotherController.doSomethingDifferent
};
var router = Marionette.AppRouter.extend({
controller: plainJsObject
});
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