You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
766 B

local addonName, addon = ...
local callbacks = {}
function addon:RegisterCallback(eventName, onEventFuncName, onEventFunc)
if not callbacks[eventName] then callbacks[eventName] = {} end
callbacks[eventName][onEventFuncName] = onEventFunc
end
function addon:UnregisterCallback(eventName, onEventFuncName)
if not callbacks[eventName] then return end
callbacks[eventName][onEventFuncName] = nil
end
function addon:UnregisterAllCallbacks(eventName)
if not callbacks[eventName] then return end
callbacks[eventName] = nil
end
function addon:Fire(eventName, ...)
if not callbacks[eventName] then return end
for onEventFuncName, onEventFunc in pairs(callbacks[eventName]) do
onEventFunc(...)
end
end