mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Fix bug in code example
This commit is contained in:
parent
a3cc2dfbda
commit
baf308ccf3
1 changed files with 7 additions and 3 deletions
|
|
@ -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.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue