Change UnRegister to Unregister, allow array to unregister more than one event/suffix

This commit is contained in:
Robin 2021-01-18 11:22:06 +01:00
parent e2e49a7816
commit 10352297aa
1 changed files with 22 additions and 8 deletions

View File

@ -1,4 +1,4 @@
local lib = LibStub:NewLibrary("LibCombatLog", 16)
local lib = LibStub:NewLibrary("LibCombatLog", 17)
if not lib then return end
local CombatLogGetCurrentEventInfo, pairs, unpack, type = CombatLogGetCurrentEventInfo, pairs, unpack, type
lib.mixinTargets = lib.mixinTargets or {}
@ -87,9 +87,16 @@ function lib:RegisterCLSuffix(suffix, funcName)
lib['regs'][suffix][self] = funcName
end
end
function lib:UnRegisterCLSuffix(suffix)
if(lib['regs'][suffix]) then
lib['regs'][suffix][self] = nil
function lib:UnregisterCLSuffix(suffix)
if(type(suffix) ~= "string" and funcName) then
for _,v in pairs(suffix) do
self:UnregisterCLSuffix(v)
end
return
else
if(lib['regs'][suffix]) then
lib['regs'][suffix][self] = nil
end
end
end
function lib:RegisterCLEvent(event,funcName)
@ -107,12 +114,19 @@ end
function lib:RegisterCLStatus(funcName)
lib['regs']['PLAYER_REGEN'][self] = funcName
end
function lib:UnRegisterCLStatus()
function lib:UnregisterCLStatus()
lib['regs']['PLAYER_REGEN'][self] = nil
end
function lib:UnRegisterCLEvent(event)
if(lib['regs'][event]) then
lib['regs'][event][self] = nil
function lib:UnregisterCLEvent(event)
if(type(event) ~= "string" and funcName) then
for _,v in pairs(event) do
self:UnregisterCLEvent(v)
end
return
else
if(lib['regs'][event]) then
lib['regs'][event][self] = nil
end
end
end
function lib:Embed(target)