mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
fix: consider updated if update_id is the latest in your dependency tree, not in entire application
This commit is contained in:
parent
121b30393c
commit
37c2dd9a5b
1 changed files with 4 additions and 1 deletions
|
|
@ -9,6 +9,7 @@ export type SourceNode<T> = {
|
||||||
|
|
||||||
export type Node<T> = {
|
export type Node<T> = {
|
||||||
cache: T,
|
cache: T,
|
||||||
|
higher_parent_update_id: number,
|
||||||
last_eval_update_id: number,
|
last_eval_update_id: number,
|
||||||
needs_queue_children: boolean,
|
needs_queue_children: boolean,
|
||||||
effect: ((T) -> T) | false,
|
effect: ((T) -> T) | false,
|
||||||
|
|
@ -151,7 +152,7 @@ end
|
||||||
local update_queue = { n = 0 } :: { n: number, [number]: Node<any> }
|
local update_queue = { n = 0 } :: { n: number, [number]: Node<any> }
|
||||||
|
|
||||||
local function evaluate_node<T>(node: Node<T>)
|
local function evaluate_node<T>(node: Node<T>)
|
||||||
if update_id == node.last_eval_update_id then return node.needs_queue_children end
|
if node.higher_parent_update_id == node.last_eval_update_id then return node.needs_queue_children end
|
||||||
if flags.strict then
|
if flags.strict then
|
||||||
local initial_value = node.cache
|
local initial_value = node.cache
|
||||||
|
|
||||||
|
|
@ -209,6 +210,7 @@ local function queue_children_for_update<T>(node: SourceNode<T>)
|
||||||
while node[j] do
|
while node[j] do
|
||||||
if node[j].last_eval_update_id == update_id then j += 1; continue end
|
if node[j].last_eval_update_id == update_id then j += 1; continue end
|
||||||
i += 1
|
i += 1
|
||||||
|
node[j].higher_parent_update_id = math.max(update_id, node[j].higher_parent_update_id)
|
||||||
update_queue[i] = node[j]
|
update_queue[i] = node[j]
|
||||||
unparent(node[j])
|
unparent(node[j])
|
||||||
end
|
end
|
||||||
|
|
@ -274,6 +276,7 @@ local function create_node<T>(owner: false | Node<any>, effect: false | (T) -> T
|
||||||
cleanups = false,
|
cleanups = false,
|
||||||
|
|
||||||
needs_queue_children = false,
|
needs_queue_children = false,
|
||||||
|
higher_parent_update_id = update_id,
|
||||||
last_eval_update_id = 0,
|
last_eval_update_id = 0,
|
||||||
context = false,
|
context = false,
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue