vide/src/batch.luau
2024-12-27 22:43:01 +00:00

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