16 lines
535 B
Lua
16 lines
535 B
Lua
--Allows to expose a function to outside the element simply
|
|
local path = string.sub(..., 1, string.len(...) - string.len(".hooks.callback"))
|
|
local context = require(path.. ".core.stack")
|
|
|
|
---Creates a callback on the 'name' field for the current element
|
|
---@param name string
|
|
---@param callback function
|
|
return function (name, callback)
|
|
local activeContext = context.getContext()
|
|
|
|
if context.element[name] then
|
|
error('callback with name '..name..' would interfere with internal fields')
|
|
end
|
|
|
|
context.element[name] = callback
|
|
end |