mirror of
https://github.com/centau/vide.git
synced 2026-08-20 23:01:37 +00:00
23 lines
545 B
Text
23 lines
545 B
Text
local flags = require "./flags"
|
|
local graph = require "./graph"
|
|
|
|
local function batch(setter: () -> ())
|
|
local already_batching = flags.batch
|
|
local from
|
|
|
|
if not already_batching then
|
|
flags.batch = true
|
|
from = graph.get_update_queue_length()
|
|
end
|
|
|
|
local ok, err: string? = xpcall(setter, debug.traceback)
|
|
|
|
if not already_batching then
|
|
flags.batch = false
|
|
graph.flush_update_queue(from)
|
|
end
|
|
|
|
if not ok then error(`error occured while batching updates: {err}`, 0) end
|
|
end
|
|
|
|
return batch
|