Skip to content

Commit

Permalink
chore(refactor): scene.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
tanvirtin committed Nov 21, 2024
1 parent f3af05f commit 3e3403c
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lua/vgit/ui/Scene.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,28 @@ local Scene = Object:extend()

function Scene:constructor()
return {
length = 0,
components = {},
state = {
length = 0,
component_order = {},
default_global_opts = {},
},
component_order = {},
default_global_opts = {},
}
end

function Scene:get_components()
local ordered_components = {}

for key, component in pairs(self.components) do
local order = self.state.component_order[key]
local order = self.component_order[key]
ordered_components[order] = component
end

return ordered_components
end

function Scene:set(key, component)
self.state.length = self.state.length + 1
self.state.component_order[key] = self.state.length
self.length = self.length + 1
self.components[key] = component
self.component_order[key] = self.length

return self
end
Expand Down

0 comments on commit 3e3403c

Please sign in to comment.