Plugin Namespace
Posted: Wed Apr 10, 2019 8:12 pm
I would like to be able to call code among Plugins or have a Global space where my plugin can call.
For instance, if I have a plugin "A" that has a function foo(myParam), I'd like to be able to call foo("test") from plugin "B". From what I can tell the namespaces for each plugin are isolated... or way down a tree branch not meant to be followed.
Here's another example, I have the following code:
which if included in each and every plugin works, but it would be nice to be able to have print() defined just once in a location where any plugin may call it. Is there a way to accomplish this or a way of contributing to the global namespace?
For instance, if I have a plugin "A" that has a function foo(myParam), I'd like to be able to call foo("test") from plugin "B". From what I can tell the namespaces for each plugin are isolated... or way down a tree branch not meant to be followed.
Here's another example, I have the following code:
Code: Select all
function print (msg) {
if (typeof(msg) == "undefined"){
// getting an undefined causes error as interpreter does not
// know if string or object
Packages.java.lang.System.out.println("undefined");
return;
}
// next line for debugging
//Packages.java.lang.System.out.println("[print 59] typeof msg = " + typeof(msg));
if (typeof(msg) == "object"){
Packages.java.lang.System.out.println(msg.toString);
} else {
Packages.java.lang.System.out.println(msg);
}
}
which if included in each and every plugin works, but it would be nice to be able to have print() defined just once in a location where any plugin may call it. Is there a way to accomplish this or a way of contributing to the global namespace?