mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Allow creation of nested tracking scopes
It turns out that handling destruction of a nested tracking scope was not as difficult as I thought and didn't need much changes
This commit is contained in:
parent
38342b3805
commit
c68d0a6c18
7 changed files with 128 additions and 137 deletions
|
|
@ -30,7 +30,7 @@ end
|
|||
local function indexes<K, VI, VO>(input: () -> Map<K, VI>, transform: (() -> VI, K) -> VO): () -> { VO }
|
||||
local owner = get_owning_scope()
|
||||
|
||||
local subowner = create_node(false, "owner")
|
||||
local subowner = create_node(false, false)
|
||||
set_owner(subowner, owner)
|
||||
|
||||
local input_cache = {} :: Map<K, VI>
|
||||
|
|
@ -67,7 +67,7 @@ local function indexes<K, VI, VO>(input: () -> Map<K, VI>, transform: (() -> VI,
|
|||
|
||||
if cv ~= v then
|
||||
if cv == nil then -- create new scope and run transform
|
||||
local scope = create_node(false, "owner")
|
||||
local scope = create_node(false, false)
|
||||
scopes[i] = scope :: Node<any>
|
||||
|
||||
local node = create_start_node(v)
|
||||
|
|
@ -125,7 +125,7 @@ end
|
|||
local function values<K, VI, VO>(input: () -> Map<K, VI>, transform: (VI, () -> K) -> VO): () -> { VO }
|
||||
local owner = get_owning_scope()
|
||||
|
||||
local subowner = create_node(false, "owner")
|
||||
local subowner = create_node(false, false)
|
||||
set_owner(subowner, owner)
|
||||
|
||||
local cur_input_cache_up = {} :: Map<VI, K>
|
||||
|
|
@ -156,7 +156,7 @@ local function values<K, VI, VO>(input: () -> Map<K, VI>, transform: (VI, () ->
|
|||
local cv = cur_input_cache[v]
|
||||
|
||||
if cv == nil then -- create new scope and run transform
|
||||
local scope = create_node(false, "owner")
|
||||
local scope = create_node(false, false)
|
||||
scopes[v] = scope :: Node<any>
|
||||
|
||||
local node = create_start_node(i)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue