Refactor codebase

This commit is contained in:
Aaron Smith 2023-08-22 15:50:03 +01:00
parent 07ae542e28
commit a3f03fd067
15 changed files with 228 additions and 128 deletions

View file

@ -7,13 +7,16 @@ local capture = graph.capture
local function watch(effect: () -> ()): () -> ()
local nodes = capture(effect :: () -> nil)
-- store aside captured nodes in new table
nodes = table.clone(nodes)
-- register effect with permanent lifetime
for _, node in next, nodes do
set_effect(node, effect, true)
end
local function unwatch()
-- unregister effect from all nodes
for _, node in next, nodes do
set_effect(node, effect, nil)
end