{"id":"rt0mmy/event","name":"event","scope":"rt0mmy","platform":"roblox","description":"Mirrored from the Wally registry.","version":"0.1.0","latest":"0.1.0","versions":["0.1.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"40879865fffbe8d23f63e3582a665d6bf65a54ae98b9e071f76e79c7e61e7857","likes":0,"downloads":0,"install":"forest install rt0mmy/event","url":"https://forest.dev/p/roblox/rt0mmy/event","files":"https://api.forest.dev/ai/package/roblox/rt0mmy/event/files","readme":"<div align=\"center\">\r\n\t<h1 style=\"color:blue;text-align:center\">Event</h1>\r\n\t<p> Fast & Lightweight Luau scriptevent </p>\r\n  \r\n  ![Luau](https://img.shields.io/badge/Lua-2C2D72?style=for-the-badge&logo=lua&logoColor=white)\r\n  <br><br>\r\n  \r\n  <img src=\"https://img.shields.io/github/forks/rT0mmy/Event?style=for-the-badge\">\r\n\r\n  <img src=\"https://img.shields.io/github/stars/rT0mmy/Event?style=for-the-badge\">\r\n\r\n  <img src=\"https://img.shields.io/github/issues/rT0mmy/Event?style=for-the-badge\">\r\n\r\n  <img src=\"https://img.shields.io/github/issues-pr/rT0mmy/Event?style=for-the-badge\">\r\n\r\n  <img src=\"https://img.shields.io/github/license/rT0mmy/Event?style=for-the-badge\">\r\n</div>\r\n\r\n<br><br><br><br>\r\n\r\n> **Warning** <br>\r\n> Event is under development\r\n\r\n<br><br>\r\n\r\n## Why Event?\r\nEvent is an API meticulously crafted to simplify event management, making your code more readable, maintainable, and responsive;\r\nIt's lightweight and straightforward structure makes it extremly easy to implement into your workflow.\r\n\r\nEvent offers intuitive and clean API structure, designed to minimize complexity while maximizing functionality.\r\n\r\n_Empower your projects with the blazing fast **Event**_\r\n <img src=\"https://cdn.discordapp.com/attachments/1110985524786761854/1209193400922935306/image.png?ex=65e6081c&is=65d3931c&hm=169d5f92420ee7f5440f2a0f02c156937735764fb1f6189ed43f71e3fdb4ac6a&\">\r\n\r\n\r\n<br><br><br>\r\n\r\n## API\r\n\r\n```lua\r\nlocal Event = require(...)\r\n```\r\n\r\n<br><br>\r\n\r\n> Creating a new ```EventObject```\r\n```lua\r\nEvent() -> Event\r\n```\r\n```lua\r\nlocal newEvent = Event()\r\n```\r\n\r\n<br><br>\r\n\r\n> Creating a new ```Connection``` for the specified ```Event```\r\n\r\n```lua\r\nEventObject:Connect(Callback: (T...)) -> Connection\r\n```\r\n```lua\r\nlocal newConnection = EventObject:Connect(function(a: number, b: number)\r\n\tprint(a + b)\r\nend)\r\n```\r\n\r\n<br><br>\r\n\r\n> Creating a new single-use ```Connection``` for the specified ```Event```\r\n\r\n```lua\r\nEventObject:Once(Callback: (T...)) -> Connection\r\n```\r\n```lua\r\nlocal newConnection = EventObject:Once(function(a: number, b: number)\r\n\tprint(a + b)\r\nend)\r\n```\r\n\r\n<br><br>\r\n\r\n> Creating a new asynchronous ```Connection``` for the specified ```Event```, thus yielding the runtime code until the event is triggered.\r\n> An optional  ```timeout``` argument defines how long the code will yield until the Wait method is terminated and therefore fails.\r\n\r\n```lua\r\nEventObject:Wait(timeout: number?) -> Connection\r\n```\r\n```lua\r\nlocal success = EventObject:Wait(2)\r\nprint(success)\r\n```\r\n\r\n<br><br>\r\n\r\n> Disconnects the ```Connection``` from Event\r\n\r\n```lua\r\nConnectionObject()\r\n```\r\n```lua\r\nnewConnection()\r\n```\r\n\r\n<br><br>\r\n\r\n> Fires the event, triggering all ```Connection```s (Callbacks)\r\n\r\n```lua\r\nEventObject:Fire(T...) -> nil\r\n```\r\n```lua\r\nEventObject:Fire(\"Hello World!\", \"\\n Luau is great!\")\r\n```\r\n\r\n<br><br>\r\n\r\n> Terminates all ```Connection```s from the ```Event```\r\n> \r\n```lua\r\nEventObject:DisconnectAll() -> nil\r\n```\r\n```lua\r\nEventObject:DisconnectAll()\r\n```\r\n\r\n<br><br>\r\n\r\n> Destroys ```Event```, therefore also disconnects all ```Connection```s\r\n\r\n```lua\r\nEventObject:Destroy() -> nil\r\n```\r\n```lua\r\nEventObject:Destroy()\r\n```\r\n\r\n<br><br><br>\r\n\r\n## API Sample Demo\r\n\r\n\r\n```lua\r\nlocal Event = require(...)\r\n\r\nlocal newEvent = Event()\r\nlocal newEventConnection = newEvent:Connect(function(...string)\r\n    print(...)\r\nend)\r\n\r\nnewEvent:Fire(\"Hello\", \"World\") -- // -> Hello World\r\n\r\nnewEventConnection()\r\nnewEvent:Fire(\"Hello\", \"World 2\") -- // Doesn't print \"Hell World 2\", because the ConnectionObject \"newEventConnection\" was disconnected beforehand.\r\n\r\n```\r\n<br>\r\n\r\n```lua\r\nlocal Event = require(...)\r\n\r\nlocal EventProcessAB = Event()\r\n\r\nfunction ProcessAB()\r\n\tlocal v = EventProcessAB:Wait(4)\r\n\t\r\n\tif v then\r\n\t\tprint('A + B = '..v)\r\n\telse\r\n\t\tprint('failed to deliver :(')\r\n\tend\r\nend\r\n\r\n\r\n```\r\n\r\n<br>\r\n\r\n```lua\r\n\r\n-- Script A\r\n\r\nlocal Event = require(...)\r\n\r\nlocal ClientEvents = {\r\n\tonClientDead = Event(),\r\n\tonClientDamaged = Event(),\r\n\tonClientStatusChanged = Event()\r\n}\r\n\r\nreturn ClientEvents\r\n\r\n-- Script B\r\n\r\nlocal ClientEvents = require(ScriptA...)\r\n\r\nlocal function TakeDamage(n)\r\n\t...\r\n\tClientEvents.onClientDamaged:Fire(n)\r\n\tif Client.Health <= 0 then\r\n\t\tClientEvents.onClientDead:Fire()\r\n\tend\r\n\t...\r\nend\r\n\r\n```\r\n\r\n\r\n","readmeTruncated":false}