mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
swap order of flush
This commit is contained in:
parent
244dd46340
commit
d341eff5c8
2 changed files with 15 additions and 5 deletions
|
|
@ -16,8 +16,8 @@ local function batch(setter: () -> ())
|
|||
local ok, err: string? = pcall(setter)
|
||||
|
||||
if not already_batching then
|
||||
flags.batch = false
|
||||
flush()
|
||||
flags.batch = false
|
||||
end
|
||||
|
||||
if not ok then throw(`error occured while batching updates: {err}`) end
|
||||
|
|
|
|||
|
|
@ -1925,14 +1925,27 @@ TEST("batch()", wrap_root(function()
|
|||
|
||||
local a0 = source(0)
|
||||
local a1 = source(1)
|
||||
local a2 = source(0)
|
||||
local updates = 0
|
||||
|
||||
derive(function()
|
||||
a0(a1() + 1)
|
||||
end)
|
||||
|
||||
derive(function()
|
||||
updates += 1
|
||||
a0()
|
||||
|
||||
batch(function()
|
||||
a2(a0())
|
||||
end)
|
||||
|
||||
return 1
|
||||
end)
|
||||
|
||||
derive(function()
|
||||
a2()
|
||||
|
||||
batch(function()
|
||||
|
||||
end)
|
||||
|
|
@ -1941,10 +1954,7 @@ TEST("batch()", wrap_root(function()
|
|||
end)
|
||||
|
||||
a1(2)
|
||||
|
||||
-- if it didnt error, all is fine!
|
||||
CHECK(true)
|
||||
|
||||
CHECK(updates == 2)
|
||||
end
|
||||
end))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue