mirror of
https://github.com/littensy/charm.git
synced 2026-10-21 11:44:08 +00:00
feat: add batch()
This commit is contained in:
parent
8a0d0977ca
commit
f0a7938703
13 changed files with 112 additions and 52 deletions
|
|
@ -4,19 +4,32 @@ type WeakMap<K, V> = types.WeakMap<K, V>
|
|||
|
||||
local listeners: WeakMap<Atom<any>, WeakMap<() -> (), unknown>> = setmetatable({}, { __mode = "k" })
|
||||
local captured: { [Atom<any>]: true } = {}
|
||||
local batched: { [Atom<any>]: true } = {}
|
||||
local capturing = false
|
||||
local batching = false
|
||||
|
||||
local function setCapturing(value: boolean)
|
||||
capturing = value
|
||||
end
|
||||
|
||||
local function shouldCapture()
|
||||
local function isCapturing()
|
||||
return capturing
|
||||
end
|
||||
|
||||
local function setBatching(value: boolean)
|
||||
batching = value
|
||||
end
|
||||
|
||||
local function isBatching()
|
||||
return batching
|
||||
end
|
||||
|
||||
return {
|
||||
listeners = listeners,
|
||||
captured = captured,
|
||||
batched = batched,
|
||||
setCapturing = setCapturing,
|
||||
shouldCapture = shouldCapture,
|
||||
isCapturing = isCapturing,
|
||||
setBatching = setBatching,
|
||||
isBatching = isBatching,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue