Lots of fixes and improvements
This commit is contained in:
Robert Jelic
2025-02-16 14:33:07 +01:00
parent 19edc4b295
commit cc7b2de51a
27 changed files with 198 additions and 208 deletions

View File

@@ -46,9 +46,8 @@ end
--- @param basalt table The basalt instance
--- @return table The newly created BaseElement instance
--- @usage local element = BaseElement.new("myId", basalt)
function BaseElement.new(props, basalt)
function BaseElement.new()
local self = setmetatable({}, BaseElement):__init()
self:init(props, basalt)
return self
end
@@ -57,11 +56,7 @@ end
--- @param basalt table The basalt instance
--- @return table self The initialized instance
function BaseElement:init(props, basalt)
if(type(props) == "table")then
for k,v in pairs(props)do
self[k] = v
end
end
self._props = props
self._values.id = uuid()
self.basalt = basalt
self._registeredEvents = {}
@@ -80,6 +75,18 @@ function BaseElement:init(props, basalt)
return self
end
--- Post initialization hook
--- @return table self The BaseElement instance
function BaseElement:postInit()
if(self._props)then
for k,v in pairs(self._props)do
self.set(k, v)
end
end
self._props = nil
return self
end
--- Checks if the element is a specific type
--- @param type string The type to check for
--- @return boolean Whether the element is of the specified type