Lots of the UI and nearly all addons do event handling, and many in similar ways. How about providing a streamlined way to do the same thing?
This wouldn't change how events work, but could perhaps provide ways to optimize event processing and would certainly provide a more straightforward way to interact with the event system.
Lua Code:
-- Register a simple handler
local function ourHandler(...)
print(...)
end
local cb = C_Events.RegisterCallback("EVENT_NAME", ourHandler)
-- Register a method handler
local t = {}
function t:EVENT_NAME(...)
print(...)
end
local cb = C_Events.RegisterCallback("EVENT_NAME", t)
-- Register a specific method handler
function t:EventHandler(...)
print(...)
end
local cb = C_Events.RegisterCallback("EVENT_NAME", t, "EventHandler")
-- Disable or enable handler (Enabled by default)
cb:Disable()
cb:Enable()
-- Release handler
cb:Destroy()
-- Register a single-use handler, automatically Destroyed on first call
local cb = C_Events.RegisterSingleCallack("EVENT_NAME", t)
-- And prematurely destroy it
cb:Destroy()