mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Fix recursive batch() use
This commit is contained in:
parent
65fe3fcf47
commit
8eb5f96c5b
5 changed files with 75 additions and 16 deletions
|
|
@ -11,13 +11,15 @@ local function batch(setter: () -> ())
|
|||
|
||||
local ok, err: string? = pcall(setter)
|
||||
|
||||
flags.batch = false
|
||||
|
||||
if not ok then throw(`error occured while batching updates: {err}`) end
|
||||
|
||||
if not already_batching then -- todo: flush anyways?
|
||||
graph.flush_update_queue()
|
||||
if not already_batching then
|
||||
flags.batch = false
|
||||
|
||||
if not already_batching then
|
||||
graph.flush_update_queue()
|
||||
end
|
||||
end
|
||||
|
||||
if not ok then throw(`error occured while batching updates: {err}`) end
|
||||
end
|
||||
|
||||
return batch
|
||||
|
|
|
|||
|
|
@ -185,8 +185,11 @@ local function queue_children<T>(node: StartNode<T>)
|
|||
update_queue.n = i
|
||||
end
|
||||
|
||||
local _flushing = false
|
||||
local function flush_update_queue()
|
||||
-- todo: test with recursive batch sets
|
||||
assert(not flushing, "recursive queue flush occured") -- todo
|
||||
_flushing = true
|
||||
|
||||
local n0 = 0
|
||||
|
||||
local i = n0 + 1
|
||||
|
|
@ -203,6 +206,8 @@ local function flush_update_queue()
|
|||
end
|
||||
|
||||
update_queue.n = n0
|
||||
|
||||
_flushing = false
|
||||
end
|
||||
|
||||
local function update<T>(root: StartNode<T>)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue