Subscribe to a Political World event
Subscribe to a Political World event
Section titled “Subscribe to a Political World event”React when Political World publishes an event instead of scanning kingdoms every update.
This assumes your addon is already registered.
Where this code goes
Section titled “Where this code goes”Register the subscription from your addon initialization path after Political World addon registration has succeeded. Keep OnPartyRenamed as a method your mod can call back into. Do not subscribe repeatedly every update/frame.
Minimal subscription
Section titled “Minimal subscription”private const string AddonId = "Example.EventAddon";
PoliticalWorldAPI.Subscribe( AddonId, "party.renamed", OnPartyRenamed);
private static void OnPartyRenamed( PoliticalWorldAPI.PoliticalEventData data){ if (data == null) return;
string oldName = data.OldValue; string newName = data.NewValue;}For the tested API 1.14.0 party.renamed path, the old/new names appeared in OldValue / NewValue rather than OldName / NewName.
Cleanup
Section titled “Cleanup”When your code no longer needs the callback, remove the exact subscription or all subscriptions owned by the addon:
PoliticalWorldAPI.Unsubscribe(AddonId, "party.renamed", OnPartyRenamed);Common mistakes
Section titled “Common mistakes”- Do not assume every event uses the same payload fields.
- Do not use a wildcard when one exact event ID is enough.
- Do not rely on one callback exception to stop other subscribers. WBML verified callback isolation.
Open the Event Bus reference for wildcard, recursion, unknown-event and diagnostics behavior.