diff --git a/docs/tut/dynamic-scoping/custom.md b/docs/tut/dynamic-scoping/custom.md index fc4258b..7a2ee62 100644 --- a/docs/tut/dynamic-scoping/custom.md +++ b/docs/tut/dynamic-scoping/custom.md @@ -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 manually and independently. - ```lua local function indexes( input: () -> Map, @@ -89,6 +88,13 @@ local function indexes( 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() local new_input = input() @@ -140,5 +146,3 @@ end 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. - -