Shared Services
Shared Services let mods share plain JavaScript APIs without ever handing raw Java objects to other mods.
API surface
Section titled “API surface”SharedServices.expose(name, apiObject)— register a service.SharedServices.call(serviceName, methodName, args?)— invoke another mod’s service method.
Exposing a Service
Section titled “Exposing a Service”SharedServices.expose("greetings", { greet: function(name) { return "Hello " + name; }});Consuming a Service
Section titled “Consuming a Service”var result = SharedServices.call( "greetings", "greet", ["Traveler"]);Service Lifecycle & Safety
Section titled “Service Lifecycle & Safety”- 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.