ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Event post hook -> Start my event function after all other addons using an event? (https://www.esoui.com/forums/showthread.php?t=2201)

Baertram 09/02/14 12:20 PM

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.

merlight 09/02/14 12:49 PM

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 :D

Baertram 09/02/14 01:09 PM

The function of that other addon is local, as it should be. Too bad :-)


All times are GMT -6. The time now is 08:14 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI