Forest Logo
search
package_2

signals

By @post-ill

Roblox

Mirrored

signal

signal is a generic, simple signal library for Roblox.

Installation

signal is available on wally, so on pesde. You can also just go to the latest release, pick the script and drop it into your project!

Usage

local signal = require(path.to.signal)
local sig = signal.new()

sig:connect(function()
  print("Hey!")
end)

sig:fire()

API

1. Signal

Class

fielddescription
signal.newcreates a signal
signal.check(v)validates if v argument is a signal
signal.connectionholds the connection class

Instance

fielddescription
signal:connect(fn)binds fn callback to be executed on every signal:fire and returns a connection
signal:once(fn)binds fn callback to be executed and dropped on the next signal:fire and returns a connection
signal:waityields until the next signal:fire and returns the fired data
signal:fire(...v)calls every connection made passing ...v data
signal:disconnectAlldrop every connection made

2. Connection

Class

fielddescription
connection.check(v)validates if v argument is a connection

Instance

fielddescription
connection.connectedindicates if the connection is still alive
connection:disconnectdrop the connection from the origin signal

Examples

local sig: signal.Signal<number, string> = signal.new()

local manualOnce = sig:connect(function(id, type)
  print(id, type)
end)

sig:connect(function(id, type)
  print(id, type)
end)

sig:once(function(id, type)
  -- Use on the next fire
end)

task.defer(function()
  sig:fire()
end)
local id, type = sig:wait()

manualOnce:disconnect()
sig:fire()
sig:fire()
sig:disconnectAll()

Issues

Feel free to open an issue if you find out that the library is not behaving as expected.

Package Details

Install command (Click to copy)


Version

1.0.0

License

Unlicense

check_circle

Safe for commercial use

infoThe package archive does not include its license text; the license is declared in its manifest metadata.

Automated license review — not legal advice.