While navigating from one screen to another onExit has to be called to free resources. However it is not triggered. This is my code:
function (BaseController, JSONModel, formatter, Filter, FilterOperator) {
"use strict";
return BaseController.extend("app.controller.Worklist", {
_oCatalog: null,
_oResourceBundle: null,
onInit: function() {
this._oView = this.getView();
},
onThirdScreen : function (oEvent) {
this.getRouter().navTo("thirdscreen", {});
},
onExit: function() {
if (this._Dialog) {
this._Dialog.destroy(true);
}
}
});
});
As @mattbtt has mentioned, views are not destroyed each time you switch to another view so the "exit" event will not be triggered. What you can do, however, is to handle the onBeforeHide/onAfterHide events from the view instead.
onInit: function() {
this._oView = this.getView();
this._oView.addEventDelegate({
onBeforeHide: function(oEvent) {
debugger;
},
onAfterHide: function(oEvent) {
debugger;
}
}, this)
}
This is the expected behavior as navigating via the routing mechanism does not destroy the corresponding view. This makes a lot of sense as views normally do not change during the lifespan of their parent component. Furthermore it would slow down the application if views need to be repeatedly instantiated if the corresponding route matches.
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