{"id":"post-ill/signal","name":"signal","scope":"post-ill","platform":"roblox","description":"Simple signal library for Roblox.","version":"1.0.0","latest":"1.0.0","versions":["1.0.0"],"license":"Unlicense","licenseRating":"safe","licenseCaveats":["The package archive does not include its license text; the license is declared in its manifest metadata."],"licenseVerified":false,"dependencies":{},"integrity":"ef351c24c0f2d4dc055a9d9e50ac81a083e9dd892ce5a42dd606427c90557507","likes":0,"downloads":0,"install":"forest install post-ill/signal","url":"https://forest.dev/p/roblox/post-ill/signal","files":"https://api.forest.dev/ai/package/roblox/post-ill/signal/files","readme":"# signal\n\n*signal* is a generic, simple signal library for Roblox.\n\n## Installation\n*signal* is available on [wally](https://wally.run/package/post-ill/signal), so on [pesde](https://docs.pesde.dev/guides/dependencies/#wally-dependencies).\nYou can also just go to the latest release, pick the [script](https://github.com/post-ill/signal/blob/master/src/init.luau) and drop it into your project!\n\n## Usage\n\n```luau\nlocal signal = require(path.to.signal)\nlocal sig = signal.new()\n\nsig:connect(function()\n  print(\"Hey!\")\nend)\n\nsig:fire()\n```\n\n## API\n\n### 1. Signal\n\n#### Class\n\n| field               | description                           |\n|---------------------|---------------------------------------|\n| `signal.new`        | creates a signal                      |\n| `signal.check(v)`   | validates if `v` argument is a signal |\n| `signal.connection` | holds the connection class            |\n\n#### Instance\n\n| field                  | description                                                                                       |\n|------------------------|---------------------------------------------------------------------------------------------------|\n| `signal:connect(fn)`   | binds `fn` callback to be executed on every `signal:fire` and returns a connection                |\n| `signal:once(fn)`      | binds `fn` callback to be executed and dropped on the next `signal:fire` and returns a connection |\n| `signal:wait`          | yields until the next `signal:fire` and returns the fired data                                    |\n| `signal:fire(...v)`    | calls every connection made passing `...v` data                                                   |\n| `signal:disconnectAll` | drop every connection made                                                                        |\n\n### 2. Connection\n\n#### Class\n\n| field                 | description                               |\n|-----------------------|-------------------------------------------|\n| `connection.check(v)` | validates if `v` argument is a connection |\n\n#### Instance\n\n| field                   | description                                |\n|-------------------------|--------------------------------------------|\n| `connection.connected`  | indicates if the connection is still alive |\n| `connection:disconnect` | drop the connection from the origin signal |\n\n## Examples\n\n```luau\nlocal sig: signal.Signal<number, string> = signal.new()\n\nlocal manualOnce = sig:connect(function(id, type)\n  print(id, type)\nend)\n\nsig:connect(function(id, type)\n  print(id, type)\nend)\n\nsig:once(function(id, type)\n  -- Use on the next fire\nend)\n\ntask.defer(function()\n  sig:fire()\nend)\nlocal id, type = sig:wait()\n\nmanualOnce:disconnect()\nsig:fire()\nsig:fire()\nsig:disconnectAll()\n```\n\n## Issues\n\nFeel free to open an [issue](https://github.com/post-ill/signal/issues/new) if you find out that the library\nis not behaving as expected.\n","readmeTruncated":false}