Skip to main content

ScriptSignal

A class which holds data and methods for ScriptSignals.

Functions

new

ScriptSignal.new() → ScriptSignal

Creates a ScriptSignal object.

Is

ScriptSignal.Is(objectany) → boolean

Returns a boolean determining if the object is a ScriptSignal.

local janitor = Janitor.new()
local signal = ScriptSignal.new()

ScriptSignal.Is(signal) -> true
ScriptSignal.Is(janitor) -> false

IsActive

ScriptSignal:IsActive() → boolean

Returns a boolean which determines if a ScriptSignal object is active.

ScriptSignal:IsActive() -> true
ScriptSignal:Destroy()
ScriptSignal:IsActive() -> false

Connect

ScriptSignal:Connect(handler(...any) → ()) → ScriptConnection

Connects a handler to a ScriptSignal object.

ScriptSignal:Connect(function(text)
	print(text)
end)

ScriptSignal:Fire("Something")
ScriptSignal:Fire("Something else")

-- "Something" and then "Something else" are printed

Once

ScriptSignal:Once(handler(...any) → ()) → ScriptConnection

Connects a handler to a ScriptSignal object, but only allows that connection to run once. Any :Fire calls called afterwards won't trigger anything.

ScriptSignal:Once(function()
	print("Connection fired")
end)

ScriptSignal:Fire()
ScriptSignal:Fire()

-- "Connection fired" is only fired once

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
ScriptSignal:Wait() → ...any

Yields the thread until a :Fire call occurs, returns what the signal was fired with.

task.spawn(function()
	print(
		ScriptSignal:Wait()
	)
end)

ScriptSignal:Fire("Arg", nil, 1, 2, 3, nil)
-- "Arg", nil, 1, 2, 3, nil are printed

Fire

ScriptSignal:Fire(...any) → ()

Fires a ScriptSignal object with the arguments passed.

ScriptSignal:Connect(function(text)
	print(text)
end)

ScriptSignal:Fire("Some Text...")

-- "Some Text..." is printed twice

DisconnectAll

ScriptSignal:DisconnectAll() → ()

Disconnects all connections from a ScriptSignal object without making it unusable.

local connection = ScriptSignal:Connect(function() end)

connection.Connected -> true
ScriptSignal:DisconnectAll()
connection.Connected -> false

Destroy

ScriptSignal:Destroy() → ()

Destroys a ScriptSignal object, disconnecting all connections and making it unusable.

ScriptSignal:Destroy()

local connection = ScriptSignal:Connect(function() end)
connection.Connected -> false
Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Creates a ScriptSignal object.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ScriptSignal"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 59,
                "path": "src/ReplicatedStorage/FastSignal/Docs.lua"
            }
        },
        {
            "name": "Is",
            "desc": "Returns a boolean determining if the object is a ScriptSignal.\n\n```lua\nlocal janitor = Janitor.new()\nlocal signal = ScriptSignal.new()\n\nScriptSignal.Is(signal) -> true\nScriptSignal.Is(janitor) -> false\n```",
            "params": [
                {
                    "name": "object",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 77,
                "path": "src/ReplicatedStorage/FastSignal/Docs.lua"
            }
        },
        {
            "name": "IsActive",
            "desc": "Returns a boolean which determines if a ScriptSignal object is active.\n\n```lua\nScriptSignal:IsActive() -> true\nScriptSignal:Destroy()\nScriptSignal:IsActive() -> false\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 92,
                "path": "src/ReplicatedStorage/FastSignal/Docs.lua"
            }
        },
        {
            "name": "Connect",
            "desc": "Connects a handler to a ScriptSignal object.\n\n```lua\nScriptSignal:Connect(function(text)\n\tprint(text)\nend)\n\nScriptSignal:Fire(\"Something\")\nScriptSignal:Fire(\"Something else\")\n\n-- \"Something\" and then \"Something else\" are printed\n```",
            "params": [
                {
                    "name": "handler",
                    "desc": "",
                    "lua_type": "(...: any) -> ()"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ScriptConnection"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 113,
                "path": "src/ReplicatedStorage/FastSignal/Docs.lua"
            }
        },
        {
            "name": "Once",
            "desc": "Connects a handler to a ScriptSignal object, but only allows that\nconnection to run once. Any `:Fire` calls called afterwards won't trigger anything.\n\n```lua\nScriptSignal:Once(function()\n\tprint(\"Connection fired\")\nend)\n\nScriptSignal:Fire()\nScriptSignal:Fire()\n\n-- \"Connection fired\" is only fired once\n```",
            "params": [
                {
                    "name": "handler",
                    "desc": "",
                    "lua_type": "(...: any) -> ()"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ScriptConnection"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 135,
                "path": "src/ReplicatedStorage/FastSignal/Docs.lua"
            }
        },
        {
            "name": "Wait",
            "desc": "Yields the thread until a `:Fire` call occurs, returns what the signal was fired with.\n\n```lua\ntask.spawn(function()\n\tprint(\n\t\tScriptSignal:Wait()\n\t)\nend)\n\nScriptSignal:Fire(\"Arg\", nil, 1, 2, 3, nil)\n-- \"Arg\", nil, 1, 2, 3, nil are printed\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "...any"
                }
            ],
            "function_type": "method",
            "yields": true,
            "source": {
                "line": 156,
                "path": "src/ReplicatedStorage/FastSignal/Docs.lua"
            }
        },
        {
            "name": "Fire",
            "desc": "Fires a ScriptSignal object with the arguments passed.\n\n```lua\nScriptSignal:Connect(function(text)\n\tprint(text)\nend)\n\nScriptSignal:Fire(\"Some Text...\")\n\n-- \"Some Text...\" is printed twice\n```",
            "params": [
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 175,
                "path": "src/ReplicatedStorage/FastSignal/Docs.lua"
            }
        },
        {
            "name": "DisconnectAll",
            "desc": "Disconnects all connections from a ScriptSignal object without making it unusable.\n\n```lua\nlocal connection = ScriptSignal:Connect(function() end)\n\nconnection.Connected -> true\nScriptSignal:DisconnectAll()\nconnection.Connected -> false\n```",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 190,
                "path": "src/ReplicatedStorage/FastSignal/Docs.lua"
            }
        },
        {
            "name": "Destroy",
            "desc": "Destroys a ScriptSignal object, disconnecting all connections and making it unusable.\n\n```lua\nScriptSignal:Destroy()\n\nlocal connection = ScriptSignal:Connect(function() end)\nconnection.Connected -> false\n```",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 204,
                "path": "src/ReplicatedStorage/FastSignal/Docs.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "ScriptSignal",
    "desc": "A class which holds data and methods for ScriptSignals.",
    "source": {
        "line": 34,
        "path": "src/ReplicatedStorage/FastSignal/Docs.lua"
    }
}