mirror of
https://github.com/centau/vide.git
synced 2026-08-20 23:01:37 +00:00
refactor: move parameter root_update_id to a new function bump_update_id
This commit is contained in:
parent
21ed76f9e0
commit
54abda629b
5 changed files with 30 additions and 12 deletions
|
|
@ -58,6 +58,11 @@ local function get_scope(): Node<unknown>?
|
|||
return scopes[scopes.n]
|
||||
end
|
||||
|
||||
local function bump_update_id()
|
||||
update_id += 1
|
||||
return update_id
|
||||
end
|
||||
|
||||
local function assert_stable_scope(): Node<unknown>
|
||||
local scope = get_scope()
|
||||
|
||||
|
|
@ -246,9 +251,8 @@ local function flush_update_queue(from: number)
|
|||
update_queue.n = from
|
||||
end
|
||||
|
||||
local function update_descendants<T>(root: SourceNode<T>, is_root_update: boolean?)
|
||||
local function update_descendants<T>(root: SourceNode<T>)
|
||||
local n0 = update_queue.n
|
||||
if is_root_update and not flags.batch then update_id += 1 end
|
||||
queue_children_for_update(root)
|
||||
|
||||
if flags.batch then return end
|
||||
|
|
@ -324,6 +328,7 @@ return table.freeze {
|
|||
flush_update_queue = flush_update_queue,
|
||||
get_update_queue_length = get_update_queue_length,
|
||||
set_context = set_context,
|
||||
bump_update_id = bump_update_id,
|
||||
scopes = scopes,
|
||||
|
||||
q = update_queue
|
||||
|
|
|
|||
|
|
@ -86,7 +86,8 @@ local function indexes<K, VI, VO>(input: () -> Map<K, VI>, transform: (() -> VI,
|
|||
output_cache[i] = result
|
||||
else -- update source
|
||||
input_nodes[i].cache = v
|
||||
update_descendants(input_nodes[i], true)
|
||||
graph.bump_update_id()
|
||||
update_descendants(input_nodes[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -170,7 +171,8 @@ local function values<K, VI, VO>(input: () -> Map<K, VI>, transform: (VI, () ->
|
|||
else -- update source
|
||||
if cv ~= i then
|
||||
input_nodes[v].cache = i
|
||||
update_descendants(input_nodes[v], true)
|
||||
graph.bump_update_id()
|
||||
update_descendants(input_nodes[v])
|
||||
end
|
||||
|
||||
cur_input_cache[v] = nil
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ local function source<T>(initial_value: T): Source<T>
|
|||
end
|
||||
|
||||
node.cache = v
|
||||
update_descendants(node, true)
|
||||
graph.bump_update_id()
|
||||
update_descendants(node)
|
||||
return v
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -285,7 +285,8 @@ local function update_spring_sources()
|
|||
output.cache = vec6_to_type[typeof(data.source_value)](x0_123, x0_456)
|
||||
end
|
||||
|
||||
update_descendants(output, true)
|
||||
graph.bump_update_id()
|
||||
update_descendants(output)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue