Strange behaviors

I feel sometimes there are strange behaviors in WOW addon codes. For example, the timing of UnregisterAllEvents() is a little bit strange.

When UnregisterAllEvents() is invoked, it will take effect in the next update (i.e., if you perform operations that fires the event in the same function, your handler will still get it). However, this is randomly happening. For example, with the following code:

local frame = CreateFrame('Frame')
frame:RegisterEvent('CHAT_MSG_SYSTEM')
frame:SetScript('OnEvent', function() print('got event') end)
C_Timer.After(1, function()
  frame:UnregisterAllEvents()
  SendChatMessage('test', 'DND')
end)

Occasionally, it shows "got event".

Furthermore, recently, I had seen "You are now Busy: DND" when I invoked SendChatMessage('', 'DND') which is expected to show "You are no longer marked Busy."

留言

這個網誌中的熱門文章

8.1.10

Official Release 8.1.8!