Skip to main content

Signal

A simple and lightweight signal implementation for Roblox.

AcidSignal provides a familiar event-driven API with a thread pool, bound arguments, and connection management via a doubly linked list.

local Signal = require(path.to.AcidSignal)

local signal = Signal.new()

signal:Connect(function(value)
	print("fired:", value)
end)

signal:Fire("hello") -- fired: hello

Functions

new

Signal.new() → Signal<A...>

Creates a new signal.

local signal = Signal.new()

Connect

Signal:Connect(
fn(
A...,
V...
) → (),--

The function to call when the signal fires

...V...--

Extra arguments appended to every call

) → Connection<A...,V...>

Connects a callback to the signal.

local connection = signal:Connect(function(value)
	print("fired:", value)
end)

-- With bound args
local connection = signal:Connect(function(value, value2)
	print(value, value2)
end, "hello")

signal:Fire("world") -- hello world

Once

Signal:Once(
fn(
A...,
V...
) → (),--

The function to call when the signal fires

...V...--

Extra arguments appended to every call

) → Connection<A...,V...>

Connects a callback that automatically disconnects after the first fire.

signal:Once(function(value)
	print("fired once:", value)
end)

Wait

Signal:Wait(
timeoutnumber?--

Maximum seconds to wait. If reached, returns false.

) → (
boolean,--

Whether the signal fired before the timeout

A...--

The arguments passed to Fire, or nil if timed out

)

Yields the current thread until the signal fires.

-- without timeout
task.defer(function() signal:Fire("Example") end)
local value = signal:Wait()
print(value) -- "Example"

-- with timeout (returns nil if timed out)
local value = signal:Wait(1)
print(value) -- nil

Fire

Signal:Fire(
...A...--

Arguments to pass to all connected callbacks

) → ()

Fires the signal, calling all connected callbacks via the thread pool. If reentrancy exceeds 256 recursive calls, a warning is emitted and the call is dropped.

signal:Fire("hello")

DisconnectAll

Signal:DisconnectAll() → ()

Disconnects all connections from the signal.

signal:DisconnectAll()

Destroy

Signal:Destroy() → ()

Alias for DisconnectAll.

signal:Destroy()
Show raw api
{
    "functions": [
        {
            "name": "Connect",
            "desc": "Connects a callback to the signal.\n```lua\nlocal connection = signal:Connect(function(value)\n\tprint(\"fired:\", value)\nend)\n\n-- With bound args\nlocal connection = signal:Connect(function(value, value2)\n\tprint(value, value2)\nend, \"hello\")\n\nsignal:Fire(\"world\") -- hello world\n```",
            "params": [
                {
                    "name": "fn",
                    "desc": "The function to call when the signal fires",
                    "lua_type": "(A..., V...) -> ()"
                },
                {
                    "name": "...",
                    "desc": "Extra arguments appended to every call",
                    "lua_type": "V..."
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Connection<A..., V...>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 70,
                "path": "lib/init.luau"
            }
        },
        {
            "name": "Once",
            "desc": "Connects a callback that automatically disconnects after the first fire.\n```lua\nsignal:Once(function(value)\n\tprint(\"fired once:\", value)\nend)\n```",
            "params": [
                {
                    "name": "fn",
                    "desc": "The function to call when the signal fires",
                    "lua_type": "(A..., V...) -> ()"
                },
                {
                    "name": "...",
                    "desc": "Extra arguments appended to every call",
                    "lua_type": "V..."
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Connection<A..., V...>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 84,
                "path": "lib/init.luau"
            }
        },
        {
            "name": "Wait",
            "desc": "Yields the current thread until the signal fires.\n```lua\n-- without timeout\ntask.defer(function() signal:Fire(\"Example\") end)\nlocal value = signal:Wait()\nprint(value) -- \"Example\"\n\n-- with timeout (returns nil if timed out)\nlocal value = signal:Wait(1)\nprint(value) -- nil\n```",
            "params": [
                {
                    "name": "timeout",
                    "desc": "Maximum seconds to wait. If reached, returns false.",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "Whether the signal fired before the timeout",
                    "lua_type": "boolean"
                },
                {
                    "desc": "The arguments passed to Fire, or nil if timed out",
                    "lua_type": "A..."
                }
            ],
            "function_type": "method",
            "source": {
                "line": 103,
                "path": "lib/init.luau"
            }
        },
        {
            "name": "Fire",
            "desc": "Fires the signal, calling all connected callbacks via the thread pool.\nIf reentrancy exceeds 256 recursive calls, a warning is emitted and the call is dropped.\n```lua\nsignal:Fire(\"hello\")\n```",
            "params": [
                {
                    "name": "...",
                    "desc": "Arguments to pass to all connected callbacks",
                    "lua_type": "A..."
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 114,
                "path": "lib/init.luau"
            }
        },
        {
            "name": "DisconnectAll",
            "desc": "Disconnects all connections from the signal.\n```lua\nsignal:DisconnectAll()\n```",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 123,
                "path": "lib/init.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "Alias for `DisconnectAll`.\n```lua\nsignal:Destroy()\n```",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 132,
                "path": "lib/init.luau"
            }
        },
        {
            "name": "new",
            "desc": "Creates a new signal.\n```lua\nlocal signal = Signal.new()\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Signal<A...>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 142,
                "path": "lib/init.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Signal",
    "desc": "A simple and lightweight signal implementation for Roblox.\n\nAcidSignal provides a familiar event-driven API with a thread pool,\nbound arguments, and connection management via a doubly linked list.\n```lua\nlocal Signal = require(path.to.AcidSignal)\n\nlocal signal = Signal.new()\n\nsignal:Connect(function(value)\n\tprint(\"fired:\", value)\nend)\n\nsignal:Fire(\"hello\") -- fired: hello\n```",
    "source": {
        "line": 19,
        "path": "lib/init.luau"
    }
}