mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Implement batched updates
No docs yet, more testing needed.
This commit is contained in:
parent
7d82fe353e
commit
ec998ccbc8
6 changed files with 123 additions and 10 deletions
23
src/batch.luau
Normal file
23
src/batch.luau
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
if not game then script = require "test/relative-string" end
|
||||
|
||||
local flags = require(script.Parent.flags)
|
||||
local throw = require(script.Parent.throw)
|
||||
local graph = require(script.Parent.graph)
|
||||
|
||||
local function batch(setter: () -> ())
|
||||
local already_batching = flags.batch
|
||||
|
||||
flags.batch = true
|
||||
|
||||
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()
|
||||
end
|
||||
end
|
||||
|
||||
return batch
|
||||
Loading…
Add table
Add a link
Reference in a new issue