Skip to main content

Signal

A small signal with the same surface as RBXScriptSignal, written in plain Luau so the core runs outside Roblox. Every Types.Signal the package exposes is one of these; you can make your own for a Hearing noise source with VluxyAI.Signal.new().

Functions​

new​

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

Creates a signal.

Connect​

Signal.Connect(
self: self,
handler: (T...) → ()
) → Connection

Runs handler on every fire until disconnected.

Once​

Signal.Once(
self: self,
handler: (T...) → ()
) → Connection

Runs handler on the next fire only.

Wait​

This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. Yields
Signal.Wait(self: self) → T...

Yields the calling thread until the next fire and returns what was fired. If the signal is destroyed while waiting, returns nothing, so a state that waited on Arrived wakes up when its agent is destroyed and can check agent:IsDestroyed().

Fire​

Signal.Fire(
self: self,
...: T...
) → ()

Fires every connected handler with the arguments, each in its own thread. Handlers connected or disconnected during a fire take effect on the next one.

DisconnectAll​

Signal.DisconnectAll(self: self) → ()

Drops every handler. The signal stays usable.

Destroy​

Signal.Destroy(self: self) → ()

Drops every handler and refuses new connections. Fires after this do nothing.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Creates a signal.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Signal<T...>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 75,
                "path": "lib/Utility/Signal.luau"
            }
        },
        {
            "name": "Connect",
            "desc": "Runs `handler` on every fire until disconnected.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "self"
                },
                {
                    "name": "handler",
                    "desc": "",
                    "lua_type": "(T...) -> ()"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Connection"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 92,
                "path": "lib/Utility/Signal.luau"
            }
        },
        {
            "name": "Once",
            "desc": "Runs `handler` on the next fire only.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "self"
                },
                {
                    "name": "handler",
                    "desc": "",
                    "lua_type": "(T...) -> ()"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Connection"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 103,
                "path": "lib/Utility/Signal.luau"
            }
        },
        {
            "name": "Wait",
            "desc": "Yields the calling thread until the next fire and returns what was fired. If the signal is\ndestroyed while waiting, returns nothing, so a state that waited on `Arrived` wakes up when\nits agent is destroyed and can check `agent:IsDestroyed()`.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "self"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "T..."
                }
            ],
            "function_type": "static",
            "yields": true,
            "source": {
                "line": 122,
                "path": "lib/Utility/Signal.luau"
            }
        },
        {
            "name": "Fire",
            "desc": "Fires every connected handler with the arguments, each in its own thread. Handlers connected or\ndisconnected during a fire take effect on the next one.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "self"
                },
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "T..."
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 148,
                "path": "lib/Utility/Signal.luau"
            }
        },
        {
            "name": "DisconnectAll",
            "desc": "Drops every handler. The signal stays usable.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "self"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 166,
                "path": "lib/Utility/Signal.luau"
            }
        },
        {
            "name": "Destroy",
            "desc": "Drops every handler and refuses new connections. Fires after this do nothing.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "self"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 178,
                "path": "lib/Utility/Signal.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Signal",
    "desc": "A small signal with the same surface as `RBXScriptSignal`, written in plain Luau so the core\nruns outside Roblox. Every [Types.Signal] the package exposes is one of these; you can make your\nown for a [Hearing] noise source with `VluxyAI.Signal.new()`.",
    "source": {
        "line": 68,
        "path": "lib/Utility/Signal.luau"
    }
}