mirror of
https://github.com/littensy/charm.git
synced 2026-10-23 05:46:27 +00:00
23 lines
557 B
Lua
23 lines
557 B
Lua
local types = require(script.Parent.types)
|
|
type Atom<T> = types.Atom<T>
|
|
type Source<T> = types.Source<T>
|
|
type WeakMap<K, V> = types.WeakMap<K, V>
|
|
|
|
local listeners: WeakMap<Atom<any>, WeakMap<() -> (), unknown>> = setmetatable({}, { __mode = "k" })
|
|
local captured: { [Atom<any>]: true } = {}
|
|
local capturing = false
|
|
|
|
local function setCapturing(value: boolean)
|
|
capturing = value
|
|
end
|
|
|
|
local function shouldCapture()
|
|
return capturing
|
|
end
|
|
|
|
return {
|
|
listeners = listeners,
|
|
captured = captured,
|
|
setCapturing = setCapturing,
|
|
shouldCapture = shouldCapture,
|
|
}
|