mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
parent
71bbaa2092
commit
d1f86a3f9e
2 changed files with 13 additions and 11 deletions
|
|
@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
### Changed
|
||||
|
||||
- Reactive scopes created within reactive scopes are now destroyed on rerun.
|
||||
- `untrack()` can be called outside of reactive scopes.
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,8 @@ local get_scope = graph.get_scope
|
|||
|
||||
local function untrack<T>(source: () -> T): T
|
||||
local scope = get_scope()
|
||||
if not scope then
|
||||
throw("cannot untrack in non-reactive scope")
|
||||
end; assert(scope)
|
||||
|
||||
if scope then
|
||||
-- sources are only tracked if the node in scope has an effect
|
||||
local effect = scope.effect
|
||||
scope.effect = false
|
||||
|
|
@ -22,6 +20,9 @@ local function untrack<T>(source: () -> T): T
|
|||
if not ok then error(result, 0) end
|
||||
|
||||
return result
|
||||
else
|
||||
return source()
|
||||
end
|
||||
end
|
||||
|
||||
return untrack
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue