{"id":"stratiz/Signal","name":"Signal","scope":"stratiz","platform":"roblox","description":"Custom event/signal implementation that avoids Roblox's deferred BindableEvent behavior.","version":"1.1.0","latest":"1.1.0","versions":["1.0.0","1.1.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"f5066c6c2a6b633fa6552f96d928f86095253cc62803e86df47664cf6789c0bb","likes":1,"downloads":4,"install":"forest install stratiz/Signal","url":"https://forest.dev/p/roblox/stratiz/Signal","files":"https://api.forest.dev/ai/package/roblox/stratiz/Signal/files","readme":"# Signal\n\nA custom event class that fires listeners immediately instead of using Roblox's deferred BindableEvent behavior.\n\n## Usage\n\n```lua\nlocal Signal = require(path.to.Signal)\n\nlocal signal = Signal.new()\n\nlocal connection = signal:Connect(function(message)\n    print(message)\nend)\n\nsignal:Fire(\"Hello\")\n\nconnection:Disconnect()\n```\n\n## Typing\n\nThe `Signal` type takes an optional generic pack describing the fired arguments. It defaults to `...any` when omitted.\n\n```lua\nlocal damaged : Signal.Signal<Player, number> = Signal.new()\n\ndamaged:Connect(function(player, amount)\n    -- player : Player, amount : number\nend)\n\ndamaged:Fire(somePlayer, 10)\n```\n\n## API\n\n### Signal.new()\n\nReturns a new signal.\n\n### Signal.connection(onDisconnect : () -> ()?)\n\nReturns a new connection object not attached to any signals. Omitting onDisconnect results in a dead connection.\n\n### Signal:Connect(callback)\n\nRuns the callback every time the signal fires. Returns a connection.\n\n### Signal:Once(callback)\n\nRuns the callback the next time the signal fires, then disconnects. Returns a connection.\n\n### Signal:Wait()\n\nYields the current thread until the next fire and returns the fired arguments.\n\n### Signal:Fire(...)\n\nCalls every listener with the given arguments. Each listener runs on its own thread.\n\n### Signal:Destroy()\n\nDisconnects every listener.\n\n## Connection\n\n### connection.Connected\n\nTrue while the connection is active.\n\n### connection:Disconnect()\n\nStops the listener from receiving further fires. Also available as `connection:Destroy()`.\n","readmeTruncated":false}