mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 21:41:50 +00:00
add events.remove
This commit is contained in:
parent
0185ef6816
commit
5930ef8285
1 changed files with 9 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ function events.on(event, func)
|
||||||
events.handlers[event] = {}
|
events.handlers[event] = {}
|
||||||
end
|
end
|
||||||
table.insert(events.handlers[event], func)
|
table.insert(events.handlers[event], func)
|
||||||
|
return func
|
||||||
end
|
end
|
||||||
|
|
||||||
function events.reset(event, func)
|
function events.reset(event, func)
|
||||||
|
|
@ -24,6 +25,14 @@ function events.reset(event, func)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function events.remove(event, handler)
|
||||||
|
local handlers = events.handlers[event]
|
||||||
|
if not handlers then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
table.remove_value(handlers, handler)
|
||||||
|
end
|
||||||
|
|
||||||
function events.remove_by_prefix(prefix)
|
function events.remove_by_prefix(prefix)
|
||||||
for name, handlers in pairs(events.handlers) do
|
for name, handlers in pairs(events.handlers) do
|
||||||
local actualname = name
|
local actualname = name
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue