mirror of
https://github.com/centau/vide.git
synced 2026-08-20 23:01:37 +00:00
Initial commit
This commit is contained in:
commit
cb002f4f27
50 changed files with 4666 additions and 0 deletions
25
src/watch.luau
Normal file
25
src/watch.luau
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
if not game then script = (require :: any) "test/wrap-require" end
|
||||
|
||||
local graph = require(script.Parent.graph)
|
||||
local set_effect = graph.set_effect
|
||||
local capture = graph.capture
|
||||
|
||||
local function watch(effect: () -> ()): () -> ()
|
||||
local nodes = capture(effect :: () -> nil)
|
||||
|
||||
nodes = table.clone(nodes)
|
||||
|
||||
for _, node in next, nodes do
|
||||
set_effect(node, effect, true)
|
||||
end
|
||||
|
||||
local function unwatch()
|
||||
for _, node in next, nodes do
|
||||
set_effect(node, effect, nil)
|
||||
end
|
||||
end
|
||||
|
||||
return unwatch
|
||||
end
|
||||
|
||||
return watch
|
||||
Loading…
Add table
Add a link
Reference in a new issue