Skip to content

Shared Services

Shared Services let mods share plain JavaScript APIs without ever handing raw Java objects to other mods.

  • SharedServices.expose(name, apiObject) — register a service.
  • SharedServices.call(serviceName, methodName, args?) — invoke another mod’s service method.
SharedServices.expose("greetings", {
greet: function(name) {
return "Hello " + name;
}
});
var result = SharedServices.call(
"greetings",
"greet",
["Traveler"]
);
  • Services are cleared on reload or disable.
  • Calls to missing services fail fast; handle absent providers gracefully.
  • Services cannot outlive their owning mod.
  • Keep APIs narrow and stable to avoid breaking consumers.