{"id":"ptekspy/signal","name":"signal","scope":"ptekspy","platform":"roblox","description":"Signal","version":"1.1.1","latest":"1.1.1","versions":["1.1.1"],"license":"Apache-2.0","licenseRating":"safe","licenseCaveats":["Modified files must carry a notice of changes. If the package ships a NOTICE file, its attributions must be preserved."],"licenseVerified":true,"dependencies":{},"integrity":"137363ff0b2bf698dc8adfe4647cf6b2cece713ceb8b20feafc28ec909623ddd","likes":0,"downloads":0,"install":"forest install ptekspy/signal","url":"https://forest.dev/p/roblox/ptekspy/signal","files":"https://api.forest.dev/ai/package/roblox/ptekspy/signal/files","readme":"# Signal\r\n\r\nA small, zero-dependency Luau Signal implementation providing a lightweight event system.\r\n\r\nFeatures\r\n- Lightweight, allocation-friendly event dispatch\r\n- Safe coroutine reuse for listener invocation\r\n- Connection objects with `Disconnect()` semantics\r\n- Variadic, generic event payloads via Luau generics\r\n\r\nInstallation\r\n\r\nInstall with `wally` (or include directly in your project):\r\n\r\n```bash\r\nwally add ptekspy/Signal\r\n```\r\n\r\nAPI\r\n\r\n- `local Signal = require(path.to.Signal.init)`\r\n- `local s = Signal.New()` — create a new `Signal` instance\r\n\r\nSignal methods\r\n- `s:Connect(fn)` — Connect a listener. Returns a `Connection` object. `fn` will be called with the arguments passed to `Fire`.\r\n- `s:Fire(...)` — Invoke all connected listeners with the provided arguments.\r\n- `s:Wait()` — Yields until the next event and returns the arguments passed to that event.\r\n- `s:FireUntil(continue_callback, ...)` — Fire listeners and stop early if `continue_callback()` returns a non-true value.\r\n\r\nConnection\r\n- `connection:Disconnect()` — Disconnect the listener so it will no longer receive events.\r\n\r\nExamples\r\n\r\nBasic usage:\r\n\r\n```lua\r\nlocal Signal = require(path.to.Signal.init)\r\n\r\nlocal s = Signal.New()\r\n\r\nlocal conn = s:Connect(function(player, amount)\r\n\tprint(player, \"received\", amount)\r\nend)\r\n\r\ns:Fire(\"Player1\", 10)\r\n\r\nconn:Disconnect()\r\n```\r\n\r\nWaiting for the next event:\r\n\r\n```lua\r\nlocal s = Signal.New()\r\nspawn(function()\r\n\ttask.wait(0.1)\r\n\ts:Fire(\"done\")\r\nend)\r\n\r\nlocal result = s:Wait()\r\nprint(result)\r\n```\r\n\r\nNotes\r\n- Listener invocation order is not guaranteed — the current implementation invokes in reverse connection order.\r\n- The implementation uses a coroutine runner reuse pattern to minimize allocations when dispatching handlers.\r\n\r\nLicense\r\n\r\nSee `LICENSE.md` for licensing information.\r\n\r\nContributing\r\n\r\nPRs and issues are welcome. Keep changes small and include tests where appropriate.\r\n","readmeTruncated":false}