Thread Tools Display Modes
09/02/14, 12:20 PM   #1
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,990
Event post hook -> Start my event function after all other addons using an event?

Hi, I've found a thread about a post hook, where a funcion will be executed after another function call.

Code:
local postHook = function(funcName, callback)
  local tmp = _G[funcName]
  _G[funcName] = function(...)
    tmp(...)
    callback()
  end
end
Is it possible to do the same with events? I would like to fire my function from the event EVENT_INVENTORY_SINGLE_SLOT_UPDATE.
But I need to be sure all other, or at least 1, addon(s) have executed their code already before my function will be called. Otherwise some data is missing or wrong.

I tried to do it with a simple zo_callLater () function, giving it 2 seconds time, but this is not working and seems not to be the good way :-)

Is there any way I can achieve this?

Thanks for your help.
  Reply With Quote
09/02/14, 12:49 PM   #2
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
I wanted the same thing once. I don't think I've come to a conclusion, I presumed handlers are called in the order they're registered, but as you have problems, it probably doesn't work that way.

If you can't find any better solution, I suggest a cheat:
- OptionallyDepend on the required addon (assuming it registers the event in its EVENT_ADD_ON_LOADED)
- unregister the event, register your own, and call the addon's function from yours
-- obviously impossible if that addon's handler is local; and here you made me thinking why am I always making handlers local
  Reply With Quote
09/02/14, 01:09 PM   #3
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,990
The function of that other addon is local, as it should be. Too bad :-)
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Event post hook -> Start my event function after all other addons using an event?


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