mirror of
https://github.com/centau/vide.git
synced 2026-08-20 23:01:37 +00:00
Refactor codebase
This commit is contained in:
parent
07ae542e28
commit
a3f03fd067
15 changed files with 228 additions and 128 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue