Originally Posted by AnrDaemon
Is there any documentation on the order of events firing? Or a library that may help managing accumulation and registration of event callbacks?
|
Registering for events is very simple and straightforward; you don't need a library to do it. If you're handling just a few events, just do an if/elseif chain in your frame's OnEvent script. If you're handling lots of events, you may want to factor out each event's handler into its own function:
Code:
local MyAddon = CreateFrame("Frame")
MyAddon:SetScript("OnEvent", function(self, event, ...) return self[event](self, ...) end)
MyAddon:RegisterEvent("SOME_EVENT_HERE")
function MyAddon:SOME_EVENT_HERE(some_arg, some_other_arg)
-- Do stuff here
end
As for the order of events, there really isn't one, outside of the initial loading process. Events indicate that things have happened in the game, and there's no fixed order for what happens in the game -- you can gain a buff, enter combat or cast a spell at any time, and so can the players around you, etc.
Was there some specific aspect of event handling you're having trouble with?