search/
Start typing to search packages!
package_2
signal
By @ptekspy
Roblox
MirroredSignal
A small, zero-dependency Luau Signal implementation providing a lightweight event system.
Features
- Lightweight, allocation-friendly event dispatch
- Safe coroutine reuse for listener invocation
- Connection objects with
Disconnect()semantics - Variadic, generic event payloads via Luau generics
Installation
Install with wally (or include directly in your project):
wally add ptekspy/Signal
API
local Signal = require(path.to.Signal.init)local s = Signal.New()— create a newSignalinstance
Signal methods
s:Connect(fn)— Connect a listener. Returns aConnectionobject.fnwill be called with the arguments passed toFire.s:Fire(...)— Invoke all connected listeners with the provided arguments.s:Wait()— Yields until the next event and returns the arguments passed to that event.s:FireUntil(continue_callback, ...)— Fire listeners and stop early ifcontinue_callback()returns a non-true value.
Connection
connection:Disconnect()— Disconnect the listener so it will no longer receive events.
Examples
Basic usage:
local Signal = require(path.to.Signal.init)
local s = Signal.New()
local conn = s:Connect(function(player, amount)
print(player, "received", amount)
end)
s:Fire("Player1", 10)
conn:Disconnect()
Waiting for the next event:
local s = Signal.New()
spawn(function()
task.wait(0.1)
s:Fire("done")
end)
local result = s:Wait()
print(result)
Notes
- Listener invocation order is not guaranteed — the current implementation invokes in reverse connection order.
- The implementation uses a coroutine runner reuse pattern to minimize allocations when dispatching handlers.
License
See LICENSE.md for licensing information.
Contributing
PRs and issues are welcome. Keep changes small and include tests where appropriate.
Package Details
Install command (Click to copy)
Version
1.1.1
License
Apache-2.0
Safe for commercial use
Modified files must carry a notice of changes. If the package ships a NOTICE file, its attributions must be preserved.
Automated license review — not legal advice.
