suppose I have a piece of code now
function globalActions(){
App = function(obj) {
console.log("This is a global App, app id is " + obj.id);
}
Page = function(obj) {
console.log("This is a global Page, page id is " + obj.id);
}
App({id: "app"});
Page({id: "page"});
myGlobalActions();
}
function pluginActions(){
let originalMyPluginActions = myPluginActions;
myPluginActions = function(){
App = undefined
Page = function(obj) {
console.log("This is a plugin Page, page id is " + obj.id);
}
originalMyPluginActions.apply(this, arguments);
}
}
function myGlobalActions(){
myPluginActions(App, Page);
}
function myPluginActions(){
let originalApp = arguments[0];
let originalPage = arguments[1];
arguments[0] = function() {
console.log("hello I try to modify the global App fn");
return originalApp.apply(this, arguments);
};
arguments[1] = function() {
console.log("hello I try to modify the global Page fn");
return originalPage.apply(this, arguments);
};
}
pluginActions();
globalActions();
it is forbidden to define App or Page (App = / Page =) in myGlobalActions. Only myGlobalActions and myPluginActions, can be modified. Could you tell me how to modify App and Page? in globalActions?