From 497a053e6019c8ef31371aeccfcc1addb8a8a2bc Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 17 Feb 2019 20:57:48 +0100 Subject: [PATCH] api: run lurker on addon event if config exists --- api/api.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/api.lua b/api/api.lua index 376893cb..fa8a556c 100644 --- a/api/api.lua +++ b/api/api.lua @@ -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()