CBI: Allow lazy loading of wizard pages (improving RAM usage)
This commit is contained in:
parent
2176dae3a0
commit
23e0a7da6a
1 changed files with 11 additions and 5 deletions
|
@ -519,10 +519,6 @@ function Delegator.__init__(self, ...)
|
|||
end
|
||||
|
||||
function Delegator.set(self, name, node)
|
||||
if type(node) == "table" and getmetatable(node) == nil then
|
||||
node = Compound(unpack(node))
|
||||
end
|
||||
assert(type(node) == "function" or instanceof(node, Compound), "Invalid")
|
||||
assert(not self.nodes[name], "Duplicate entry")
|
||||
|
||||
self.nodes[name] = node
|
||||
|
@ -562,7 +558,17 @@ function Delegator.set_route(self, ...)
|
|||
end
|
||||
|
||||
function Delegator.get(self, name)
|
||||
return self.nodes[name]
|
||||
local node = self.nodes[name]
|
||||
|
||||
if type(node) == "string" then
|
||||
node = load(node)
|
||||
end
|
||||
|
||||
if type(node) == "table" and getmetatable(node) == nil then
|
||||
node = Compound(unpack(node))
|
||||
end
|
||||
|
||||
return node
|
||||
end
|
||||
|
||||
function Delegator.parse(self, ...)
|
||||
|
|
Loading…
Reference in a new issue