The usage is super simple, below is some sample code!
local Eventify = require(game:GetService("ServerScriptService").Eventify)
--// Create a new event
local Event = Eventify.new()
--// Connect a function to the event
Event:Connect(print)
--// Fire the event!
Event:Fire("Hello world!")
It also comes with some additional functions, such as Event:DisconnectAll(), Connection:Wait() and Connection:Disconnect()
Function Reference
function Eventify.new(Name: string) -> Event
Creates a new event object
- The name argument can be used to access the event across multiple scripts
function Event:Fire(...) -> void
Fires all connections in of the event with the inputted arguments
function Event:Connect(Callback: function) -> Connection
Creates a new connection
- The callback argument is a function which is called when the event is fired
function Event:Wait() -> void
Yields the thread until the event has been fired
function Event:DisconnectAll() -> void
Disconnects all event connections
function Connection:Disconnect() -> void
Disconnects the connection
Thank you!
Source Code
local Eventify = {}
local EventCache = {}
local ConnectionCache = {}
local Event = {}
Event.__index = Event
local Connection = {}
Connection.__index = Connection
function Eventify.new(Name: string?)
if Name and EventCache[Name] then return EventCache[Name] end
local NewEvent = {}
setmetatable(NewEvent,Event)
ConnectionCache[NewEvent] = {}
if Name then
EventCache[Name] = NewEvent
end
return NewEvent
end
function Event:Connect(callback: (any) -> any)
local NewConnection = {}
setmetatable(NewConnection,Connection)
ConnectionCache[self][NewConnection] = callback
local event = self
function Connection:Disconnect()
ConnectionCache[event][NewConnection] = nil
end
return NewConnection
end
function Event:Fire(...)
for _,Callback in pairs(ConnectionCache[self]) do
task.defer(Callback,...)
end
end
function Event:Wait()
local IsWaiting = true
local Connection = self:Connect(function() IsWaiting = false end)
repeat task.wait() until IsWaiting == false
Connection:Disconnect()
end
function Event:DisconnectAll()
ConnectionCache[self] = {}
end
return Eventify
Community Resources is people who wish to give away resources to the community in which theyāve created. Itās up to others discretion if they use this over something such as āGoodSignalā; on top of that this isnāt necessarily a bad resource to learn off of for basic entry.
@Starnamics Donāt undervalue your work; this isnāt bad by any means. While there are some rooms for improvement, it serves its purpose unless weāre getting in to microperformance.
There needs to be a distinction made between work which is original from other alternatives, and posts that essentially litter the category. Your argument is very dangerous, for it could go down a slippery slope of allowing any type of posts, with the reason of ātheyāre learningā.
I highly donāt recommend you to use one of my work as a rebuttal as this could have be deemed as off-topic.
Commander is not the first administration system in Roblox, it follows some standards from other existing administration systems. However, it has some unique features that really stands out and justifies its existence in the community resources category.
Similar product is fine, but if it doesnāt have any unique features compared to existing products, thereās not enough to convince others to switch over or adopt.
@Starnamics dont mind pyseph, i made a module like this just a few days ago and he was up in my thread spreading the same negativity. none of us are here to be the best, we are just here to share what we can do. great job!
This was completely not needed. The community resources category should not be locked for already existing resources. The whole point of this category is to share what you make, as it relates to Roblox development, with the community. If you think itās āsubparā then donāt use it; donāt harass the creator claiming ābetter stuff exists so this is pointless.ā
You donāt know how much effort they put into this resource. Just because it isnāt up to your āstandardā doesnāt mean itās useless. Also attacking someoneās work and then shielding your own work when the roles get switched is kind of silly. Donāt post just to criticize someoneās resource unless you actually want to contribute to making it better.
@Starnamics Sorry you had to deal with these people. Keep up the great work!
Sureā¦ I donāt think a signal library is that hard to implement. This is very alike Reselimās implementation except it uses the task library, not the coroutine library
I am not? Not so sure how do you think but having discussion about another librarys/toolings that has no relation with this oneā¦ itās just weird and technically can be flagged as off-topic.
Even if it was not difficult, I still spent time making it.
The relation is that you were saying mine was not beneficial as there are others that are similar, so I was saying the same about admin systems, which there are plenty of but people still use different ones instead of the most popular ones.
Again, completely not needed. Stop shaming peopleās work. This resource may be beneficial to some people. If you donāt like it, donāt use it and donāt harass the creator.
This isnāt littering the category - itās open source, and really is nothing compared to what is sometimes spammed here. Regardless of if thereās a better alternative or not, this isnāt hurting anybody, itās simply an alternative, especially if you the user wants to understand how a module like this is made, since many of these other modules like GoodSignal are rather complicated for a beginner to understand.
tl;dr aside from blatant spam, having more resources does nothing but benefit developers.
I totally agree. If anyone is littering anything, its pyseph. I made a signal module post here a few days ago and pyseph was in the thread doing exactly the same thing, putting down my work by asking how its any better than an existing thing. He seems to only care about putting down others work rather than praising any sort of accomplishment they may have made, appreciating the good intentions, or acknowledging that a simpler module may not perform as well but may be much easier for a beginner to understand and expand upon.
I donāt really think a distinguishment needs to be made versus other solutions. The whole purpose of this category is to allow developers to share their work for others to use and learn from.
While you may have not intended to sound degrading, it comes off as such because you are essentially telling anyone who views this thread to not use it because there are other resources that share similar concepts.
There is an irony to be made, as none of our posts, including my own, are relevant to the topic of the module. If you would like to properly discuss the correctness of my post, my PMs are open.
He clearly made it for fun, And theres no problem with that. You go to the store, you see two similar products, one simpler and another more better, It does not matter which one you buy as its your choice, and your allowed to make similar products. Which proves your point wrong.
If you always want to see āusefulā and āoriginalā resources then make your own.