I'm having issues destroying a Marionette controller. I'm still wrapping my brains around Marionette, and more specifically Backbone garbage collection....
This controller instantiates several views, each of which may have several bound event listeners. The code looks something like this:
myController.js
---------------
Marionette = require('backbone.marionette');
MyView = require('path/to/myView');
var MyController = Marionette.Controller.extend({
initialize: function(options) {
console.log('init');
}
onDestroy: function() {
console.log('should be destroyed');
}
showData: function() {
console.log('create view');
myView = new MyView();
}
});
appController.js
----------------
MyController = require('path/to/myController');
var controller = new MyController()
controller.showData();
controller.destroy();
output:
//init
//create view
//should be destroyed
Controller is still around, even though onDestroy does fire..
Could this be an issue with views still having bound event listeners? My apologies if the code looks weird... translating this from coffeescript.