Forest Logo
search
package_2

Signal

By @stratizverified

Roblox

Signal

A custom event class that fires listeners immediately instead of using Roblox's deferred BindableEvent behavior.

Usage

local Signal = require(path.to.Signal)

local signal = Signal.new()

local connection = signal:Connect(function(message)
    print(message)
end)

signal:Fire("Hello")

connection:Disconnect()

Typing

The Signal type takes an optional generic pack describing the fired arguments. It defaults to ...any when omitted.

local damaged : Signal.Signal<Player, number> = Signal.new()

damaged:Connect(function(player, amount)
    -- player : Player, amount : number
end)

damaged:Fire(somePlayer, 10)

API

Signal.new()

Returns a new signal.

Signal.connection(onDisconnect : () -> ()?)

Returns a new connection object not attached to any signals. Omitting onDisconnect results in a dead connection.

Signal:Connect(callback)

Runs the callback every time the signal fires. Returns a connection.

Signal:Once(callback)

Runs the callback the next time the signal fires, then disconnects. Returns a connection.

Signal:Wait()

Yields the current thread until the next fire and returns the fired arguments.

Signal:Fire(...)

Calls every listener with the given arguments. Each listener runs on its own thread.

Signal:Destroy()

Disconnects every listener.

Connection

connection.Connected

True while the connection is active.

connection:Disconnect()

Stops the listener from receiving further fires. Also available as connection:Destroy().

Package Details

Install command (Click to copy)


Version

1.1.0

License

MIT

check_circle

Safe for commercial use

Automated license review — not legal advice.