Minor refactors

Also fixed potential bug with `create()` being called recursively if a
property binding passed as a property to `create()` also calls
`create()`
This commit is contained in:
Aaron Smith 2023-11-20 16:53:30 +00:00
parent 8eb5f96c5b
commit c288cb92c4
16 changed files with 169 additions and 130 deletions

View file

@ -9,14 +9,14 @@ local evaluate_node = graph.evaluate_node
local set_owner = graph.set_owner
local track = graph.track
local destroy = graph.destroy
local get_owning_scope = graph.get_owning_scope
local assert_owning_scope = graph.assert_owning_scope
local open_scope = graph.open_scope
local close_scope = graph.close_scope
type Map<K, V> = { [K]: V }
local function switch<T, U>(source: () -> T): (map: Map<T, ((() -> U)?)>) -> () -> U?
local owner = get_owning_scope()
local owner = assert_owning_scope()
return function(map)
local last_scope: Node<false>?
@ -35,7 +35,7 @@ local function switch<T, U>(source: () -> T): (map: Map<T, ((() -> U)?)>) -> ()
if component == nil then return nil end
if type(component) ~= "function" then
throw("map must map a value to a function")
throw "map must map a value to a function"
end
local new_scope = create_node(false, false)