Originally Posted by LudiusMaximus
What you suggest is a good way to check if an event exists! Do you think it is more efficient than my solution:
Lua Code:
if not APIDocumentation then LoadAddOn("Blizzard_APIDocumentation"); end local allEvents = APIDocumentation:GetAPITableByTypeName("event") local EventExists = function(event) local eventExists = false for k, v in pairs(allEvents) do if event == v.LiteralName then eventExists = true break end end return eventExists end
My problem was really AceEvent's UnregisterAllEvents() function that tries to unregister non-existing events that were tried to be registered using pcall(). Maybe AceEvent assumes that a script will never continue after its RegisterEvent() fails. So it does not bother to remove a non-existent event from its own table of (putatively) registered events...?
|
Personally I'd would use my solution because it doesn't rely on Blizzard to provide a up-to-date and complete documentation (also you don't need to load the addon which itself takes about 2-3 times as long as it takes to check 10000 events for existance with the pcall approach).