Thread Tools Display Modes
01-03-14, 05:08 PM   #1
bsmorgan
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 219
Is the order addons receive events predictable?

If multiple addons register for the same event (i.e. MAIL_INBOX_UPDATE) can the order of delivery be predicted? Is it the same as the order in which they registered?

Thanks!
  Reply With Quote
01-03-14, 05:25 PM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Originally Posted by bsmorgan View Post
Is it the same as the order in which they registered?
As far as I know, yes.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
01-03-14, 06:39 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
It's undefined. So, it works the same way as iterating over a table with pairs -- you might get the same order consistently, but it's not guaranteed. For an addon you plan to publish, you shouldn't depend on it. If you need to make sure your event handler always runs after another addon's event hander, use a hook.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-04-14, 01:34 PM   #4
bsmorgan
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 219
Thanks for the answers.

As it turns out, MAIL_INBOX_UPDATE fires so many times that it doesn't matter which addon sees it first. My addon needs to know if a mail is new and who sent it. Those two values become valid in different MAIL_INBOX_UPDATE events.

I had to hook GetInboxText (which sets wasRead) to keep track of new mail if some other addon reads the message before the sender is valid. Once I know which mails are new, I can defer processing them until the sender is valid.
  Reply With Quote
01-08-14, 06:46 PM   #5
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Originally Posted by Phanx View Post
It's undefined. So, it works the same way as iterating over a table with pairs -- you might get the same order consistently, but it's not guaranteed. For an addon you plan to publish, you shouldn't depend on it. If you need to make sure your event handler always runs after another addon's event hander, use a hook.
Is that really a fact? I can not recall my assumption ever having failed me before.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
01-08-14, 06:52 PM   #6
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
It depends on the event(s), really. Safer to just assume they're all unreliable.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Is the order addons receive events predictable?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off