Fix bug in code example

This commit is contained in:
aaron 2024-11-04 23:27:28 +00:00
parent a3cc2dfbda
commit baf308ccf3

View file

@ -76,7 +76,6 @@ between reruns, we cannot use `untrack()` anymore which automatically destroys
on rerun; we must use `root()` where the lifetime of each scope is managed on rerun; we must use `root()` where the lifetime of each scope is managed
manually and independently. manually and independently.
```lua ```lua
local function indexes<I, VI, VO>( local function indexes<I, VI, VO>(
input: () -> Map<I, VI>, input: () -> Map<I, VI>,
@ -89,6 +88,13 @@ local function indexes<I, VI, VO>(
destroy: () -> () destroy: () -> ()
}?> }?>
-- destroy all scopes if the parent scope is destroyed
cleanup(function()
for _, cache in index_caches do
assert(cache).destroy()
end
end)
return derive(function() return derive(function()
local new_input = input() local new_input = input()
@ -140,5 +146,3 @@ end
Though the above functions are already provided to you by Vide, this serves as Though the above functions are already provided to you by Vide, this serves as
an example for how you may create your own dynamic scope functions. an example for how you may create your own dynamic scope functions.