Reputation: 101
I have a problem unloading a custom utility module in Fiori Launchpad. I'd like to do that to clean up resources.
Module definition:
jQuery.sap.declare("sap.ui.demo.tdg.util.Formatter");
sap.ui.demo.tdg.util.Formatter = {
methodCall: function() {
...
Module is loaded in Component init:
myComponentPath.Component.prototype.init = function(){
jQuery.sap.require("sap.ui.demo.tdg.util.Formatter");
sap.ui.demo.tdg.util.Formatter.methodCall(); <- error happens here when opening 2nd time
I tried to set the module to null on Component destroy but then I get undefined on sap.ui.demo.tdg.util.Formatter when opening the application second time in Fiori Launchpad:
myComponentPath.Component.prototype.destroy = function(){
sap.ui.demo.tdg.util.Formatter = null;
Or am I just paranoid and should not care about the resources been cleaned up properly. :)
Thanks!
Upvotes: 0
Views: 972
Reputation: 1926
You can try it with:
jQuery.sap.unloadResource("some/util/Formatter.js", false, true, true);
EDIT: jQuery.sap.require loads an resource and saves it into an internal map called mModules. With unloadResource you can remove an entrie from this map. The parameters behind the path describes how to handle dependencies like global vars.
But you can read the documentation yourself here.
Upvotes: 1