-- This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
-- To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/
-- or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

local MereHealingFrames, privateVars = ...
MereHealingFrames.Utils = {}

function MereHealingFrames.Utils.ReplaceEventHandler(table, eventHandlerName, newEvent, updateFunction, name)
    local eventHandle = table[eventHandlerName]

    if (eventHandle) then
        Command.Event.Detach(eventHandle, updateFunction, name, nil, "MereHealingFrames")
    end

    table[eventHandlerName] = newEvent

    if newEvent then
        Command.Event.Attach(newEvent, updateFunction, name)
    end
end