Forest Logo
search
package_2

lightsignal

By @luj-s

Roblox

Mirrored

Introduction

LightSignal is a minimal Roblox (and Lune) Signal implementation, inspired by GoodSignal, with a twist: there's no Connections. Instead, a Signal object, thanks to metatables, is simply a list of it's Callbacks.

Installation

Wally

Add

lightsignal = "luj-s/lightsignal@0.1.0"

in your wally.toml, under the [dependencies] table.

Or..

Download the model from the latest release.

Usage

local LightSignal = require("path/to/lightsignal")
local Signal : LightSignal.Signal = LightSignal.new()

-- Connect
-- Returns the index the callback resides at.
local CallbackIndex = Signal:Connect(function(message)
	print(message)
end)

-- Once
-- Same thing as Connect.
local CallbackIndex = Signal:Once(function(message)
	print(message)
end)

-- Wait
local v = Signal:Wait()

-- Checking if a callback is connected to a signal.
local Connected : boolean = if Signal[CallbackIndex] then true else false

-- Fire
Signal:Fire("Hello, World!")

-- Disconnect
Signal[CallbackIndex] = nil

-- Disconnect all
table.clear(Signal)

GoodSignal performance comparison

TestLightSignal (μs)GoodSignal (μs)
ConnectAndDisconnect0.10.3
WaitOnEvent4.14.2
FireManyCallbacks5.05.0
FireWithNoConnections0.10.0
CreateAndFire1.21.3
Fire0.90.8
FireYieldingCallback3.93.0
FireManyArguments1.00.9

Tests source code.

Package Details

Install command (Click to copy)


Version

0.1.3

License

GPL-3.0

error

Legal risk for closed-source games

infoStrong copyleft: shipping this in your game plausibly requires releasing your game's entire source under GPL-3.0. Not recommended for closed-source projects.

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

Automated license review — not legal advice.