mirror of
https://github.com/Ukendio/jecs.git
synced 2025-06-20 00:09:18 +00:00
28 lines
482 B
Text
28 lines
482 B
Text
local function collect<T...>(
|
|
signal: {
|
|
Connect: (RBXScriptSignal<T...>, fn: (T...) -> ()) -> RBXScriptConnection
|
|
}
|
|
): () -> (T...)
|
|
local enqueued = {}
|
|
|
|
local i = 0
|
|
|
|
local connection = (signal :: any):Connect(function(...)
|
|
table.insert(enqueued, { ... })
|
|
i += 1
|
|
end)
|
|
|
|
return function(): any
|
|
if i == 0 then
|
|
return
|
|
end
|
|
|
|
i -= 1
|
|
|
|
local args: any = table.remove(enqueued, 1)
|
|
|
|
return unpack(args)
|
|
end, connection
|
|
end
|
|
|
|
return collect
|