api: run lurker on addon event if config exists

This commit is contained in:
shagu
2019-02-17 20:57:48 +01:00
parent 0a376bc251
commit 497a053e60
+8
View File
@@ -340,9 +340,17 @@ end
function pfUI.api.HookAddonOrVariable(addon, func)
local lurker = CreateFrame("Frame", nil)
lurker.func = func
lurker:RegisterEvent("ADDON_LOADED")
lurker:RegisterEvent("VARIABLES_LOADED")
lurker:RegisterEvent("PLAYER_ENTERING_WORLD")
lurker:SetScript("OnEvent",function()
-- only run when config is available
if event == "ADDON_LOADED" and not this.foundConfig then
return
elseif event == "VARIABLES_LOADED" then
this.foundConfig = true
end
if IsAddOnLoaded(addon) or _G[addon] then
this:func()
this:UnregisterAllEvents()