This commit is contained in:
Aaron Smith 2023-08-02 16:12:05 +01:00
parent f7ce5f024d
commit 7cdcebf03c
11 changed files with 367 additions and 233 deletions

View file

@ -1,9 +1,12 @@
--!nocheck
-- wrapped task library for use in pure luau
local task = { spawn = function(thread, ...)
local ok, err = coroutine.resume(thread, ...)
if not ok then error(err, 3) end
end }
export type Type = RBXScriptSignal & { Fire: (Type, ...any)-> () }
----------------------------------------------------------------------------------------------------
-- Batched Yield-Safe Signal Implementation --
-- This is a Signal class which has effectively identical behavior to a --
@ -106,10 +109,12 @@ setmetatable(Connection, {
local Signal = {}
Signal.__index = Signal
function Signal.new()
Signal.__type = "RBXScriptSignal"
function Signal.new(): Type
return setmetatable({
_handlerListHead = false,
}, Signal)
}, Signal) :: any
end
function Signal:Connect(fn)
@ -174,14 +179,4 @@ function Signal:Once(fn)
return cn
end
-- Make signal strict
setmetatable(Signal, {
__index = function(tb, key)
error(("Attempt to get Signal::%s (not a valid member)"):format(tostring(key)), 2)
end,
__newindex = function(tb, key, value)
error(("Attempt to set Signal::%s (not a valid member)"):format(tostring(key)), 2)
end
})
return Signal