{"id":"luj-s/lightsignal","name":"lightsignal","scope":"luj-s","platform":"roblox","description":"Signal implementation","version":"0.1.3","latest":"0.1.3","versions":["0.1.0","0.1.1","0.1.2","0.1.3"],"license":"GPL-3.0","licenseRating":"unsafe","licenseCaveats":["Strong copyleft: shipping this in your game plausibly requires releasing your game's entire source under GPL-3.0. Not recommended for closed-source projects.","The package archive does not include its license text; the license is declared in its manifest metadata."],"licenseVerified":false,"dependencies":{},"integrity":"7bac1f61d6650967ccc310cb211831272ccff7c6c88ea90c1d8c3dac2b459ae2","likes":0,"downloads":0,"install":"forest install luj-s/lightsignal","url":"https://forest.dev/p/roblox/luj-s/lightsignal","files":"https://api.forest.dev/ai/package/roblox/luj-s/lightsignal/files","readme":"# Introduction\nLightSignal is a minimal Roblox (and Lune) Signal implementation, inspired by [GoodSignal](https://github.com/stravant/goodsignal), with a twist: there's no Connections. Instead, a Signal object, thanks to metatables, is simply a list of it's Callbacks.\n\n# Installation\n## Wally\nAdd\n```\nlightsignal = \"luj-s/lightsignal@0.1.0\"\n```\nin your `wally.toml`, under the `[dependencies]` table.\n## Or..\nDownload the model from the [latest release](https://codeberg.org/lujs/lightsignal/releases/latest).\n\n# Usage\n```lua\nlocal LightSignal = require(\"path/to/lightsignal\")\nlocal Signal : LightSignal.Signal = LightSignal.new()\n\n-- Connect\n-- Returns the index the callback resides at.\nlocal CallbackIndex = Signal:Connect(function(message)\n\tprint(message)\nend)\n\n-- Once\n-- Same thing as Connect.\nlocal CallbackIndex = Signal:Once(function(message)\n\tprint(message)\nend)\n\n-- Wait\nlocal v = Signal:Wait()\n\n-- Checking if a callback is connected to a signal.\nlocal Connected : boolean = if Signal[CallbackIndex] then true else false\n\n-- Fire\nSignal:Fire(\"Hello, World!\")\n\n-- Disconnect\nSignal[CallbackIndex] = nil\n\n-- Disconnect all\ntable.clear(Signal)\n```\n\n# GoodSignal performance comparison\n|           Test          |    LightSignal (μs)     |      GoodSignal (μs)    |\n|-------------------------|-------------------------|-------------------------|\n| ConnectAndDisconnect    |           0.1           |           0.3           |\n| WaitOnEvent             |           4.1           |           4.2           |\n| FireManyCallbacks       |           5.0           |           5.0           |\n| FireWithNoConnections   |           0.1           |           0.0           |\n| CreateAndFire \t\t\t\t\t|           1.2           |           1.3           |\n| Fire \t\t\t\t\t\t\t\t\t  |           0.9           |           0.8           |\n| FireYieldingCallback    |           3.9           |           3.0           |\n| FireManyArguments       |           1.0           |           0.9           |\n\nTests [source code](https://codeberg.org/lujs/lightsignal/src/branch/master/benchmark/benchmark.server.luau).\n","readmeTruncated":false}