EventRegistry

: Source: SharedXML\GlobalCallbackRegistry.lua
EventRegistry is a FrameXML utility library for handling callbacks, similar to CallbackHandler-1.0. It inherits from CallbackRegistryMixin
==CallbackRegistry==
* CallbackRegistryMixin:RegisterCallback(event, func, [owner], ...) : owner - Registers a callback to a custom defined event.
* CallbackRegistryMixin:UnregisterCallback(event, owner)
* CallbackRegistryMixin:TriggerEvent(event, ...) - Fires a callback event.
==EventRegistry==
* EventRegistry:RegisterFrameEventAndCallback(frameEvent, func, [owner], ...) : owner - Registers a callback to a Frame Event (e.g. PLAYER_ENTERING_WORLD)
* EventRegistry:UnregisterFrameEventAndCallback(frameEvent, owner)
==Details==
* There is a caveat, if one of the functions registered through the event registry takes too long to execute (script timeouts) then all the other callbacks for the same event in the registry may also not get executed.
* EventRegistry events and their payload are shown in the Event Trace panel when triggered.
: 
==Example==
A common use case is to register for Blizzard callback events, for example when the Mount Journal is opened.
EventRegistry:RegisterCallback("MountJournal.OnShow", function()
	print("showed the mount journal")
end)
Registers two callbacks to a custom event.
local function a(ownerID, ...)
	print("a", ...) -- prints "a", "foo", "bar"
end
local function b(ownerID, ...)
	print("b", ...) -- prints "b", "foo", "bar"
end
EventRegistry:RegisterCallback("HelloWorld.OnSomething", a)
EventRegistry:RegisterCallback("HelloWorld.OnSomething", b)
-- /run EventRegistry:TriggerEvent("HelloWorld.OnSomething", "foo", "bar")
===Unregistering===
Callbacks are unregistered by owner handle. When registering a callback the owner can be a table, function or string; if omitted it will be assigned an internal number.
local cb = function(ownerID, journal, tabID)
	print("switched to collections tab", tabID)
end
local ownerID = EventRegistry:RegisterCallback("CollectionsJournal.TabSet", cb) -- omitted owner param
Example = ownerID
-- /run EventRegistry:UnregisterCallback("CollectionsJournal.TabSet", Example)
===Frame Events===
This allows you to respond to events without having to create a frame and registering an event to it.
EventRegistry:RegisterFrameEventAndCallback("PLAYER_ENTERING_WORLD", function(ownerID, ...)
	print(...) -- on login this prints: "foo", "bar", true, false
end, nil, "foo", "bar")
===Private CallbackRegistry===
Creates your own CallbackRegistry object instead of using EventRegistry.
local cr = CreateFromMixins(CallbackRegistryMixin)
cr:OnLoad()
cr:SetUndefinedEventsAllowed(true)
cr:RegisterCallback("MyCustomEvent", function(ownerID, ...)
	print("a", ...) -- prints "a", "foo", "bar"
end)
Example = cr
-- /run Example:TriggerEvent("MyCustomEvent", "foo", "bar")
==External links==
 for TriggerEvent