helium/hooks/callback.lua
Elmārs Āboliņš 5309f35dfc implemented the rest of the state callbacks
redid layout
luadoc + emmylua annotations everywhere
grid layout started
2021-06-15 03:36:09 +03:00

16 lines
536 B
Lua

--Allows to expose a function to outside the element simply
local path = string.sub(..., 1, string.len(...) - string.len(".hooks.onDestroy"))
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