THIS POST IS OUTDATED
FLEXSignal is a top-performance signal handling system. FLEXSignal allows you to create signals-like instances that you can use for event-based programming while reducing the memory it collects as much as possible without affecting the UX.
FLEXSignal is the first ( as far as I know) system that doesn’t rely on bindableEvents. It uses a cache-based system to lower down the memory collection as much as possible.
FLEXSignal is 100% free and open-source and available for anybody to use. You can get it by using this link: FLEXSignal - Roblox
FLEXSignal always try to make it easier for you to use it; which it achieves it amazingly using the following features that you can see in the RblxSignals(Default Events).
Features
Mutli-usage: FLEXSignal offer you the same usage experience when you are working with the normal events from multiple scripts. Just reference the signal with the ID you have created it with and then you are good to go!
Multi-Listening: FELXSignal offers you a multi-listening system where you can connect more functions to a signal(Although it is possible to make one event for everything, I discourage you from doing so).
Performance by design: FLEXSignal, unlike most of the other signal systems, doesn’t rely on BindableEvents which reduces the memory that is taken by signal. The memory differs depending on how many functions you connect and how you clear them, and the ID itself.
FLEXSignal offers you a rich API to create your own signals similar to RblxSignals without the use of BindableEvents which is simple as if like you are using a default event!
Docs
API Doc
FLEXSignal.new(
int
ID,int
Mode)
Creates a signal and creates a cache table for it in the global cache table.
FLEXSignal:Connect(
int
ConnectionID,function
method)
Connects a function while indexing the connection as ID. Returns a table with Disconnect that removes the connection.
FLEXSignal:Disconnect(
int
ConnectionID)
Removes the connection.
FLEXSignal:DisconnectAll()
Removes all the connections that are attached to the signal.
FLEXSignal:Fire(
any
…)
Fires the signal with the provided arguments
FLEXSignal:Destroy()
Removes the signal’s cache. Set any variables that reference the signal to nil.
FLEXSignal:GetSignal(
int
ID)
Returns the signal that is associated with the given ID . ForceFind means that if the function didn’t find the signal, it won’t yield.
Simple Project and Best Practices
In this section, you will create your first signal with FLEXSignal and know the best practices to follow!
Preparing
First get the model and then put it in the Serverstorage. Now create two scripts, 1 called Connector and the other one Handler and both in the serverscriptservice.
In the both scripts, reference the FLEXSignal module like the following:
local FLEXSignal = require(game.ServerStorage.FLEXSignal)
And now, you are good to go to the next step!
Creating a signal and connecting it and then Fire it
After you require the modulescript, you should create a new signal object in both of the scripts like this:
local NewSignal = FLEXSignal.new(1)
Now, why we choose 1? Well, you can put any number if it isn’t used before or 0.
Well, let’s make the crazy stuff! Let’s connect it to a function that will simply kick the provided player! We will start the connection in the Connector
script by the following:
local Connection = NewSignal:Connect(2, function(Player)
Player:Kick("you are bad boy");
end)
Now let’s break down what’s happening here; When you connect the function, you pass two arguments, the first one is the ID that indexes the connection in the connections table and the second one, is well, the method that will be ran when the signal fires.
Now, in the Handler
script, reference the signal object by the following:
local Signal = FLEXSignal:GetSignal(1)
It is pretty basic here, we get the signal by getting it from the cache that is saved in the modulescript using the ID we originally created it with. Please keep in mind that GetSignal() will yield for wait for the signal to be created for 20 seconds, if the said time passes but it still didn’t find the signal it will return nil. You can disable this behavior by adding a second argument that is equal to true; as a result, the function will return nil right away.
To fire the signal, we can do the following:
Signal:Fire(Player)
Best Practices
Use Disconnect() on connection that are no longer used
Use Destroy() on signals that are no longer used; FLEXSignal doesn’t have an automatic destroying signals due to the signals not being attached to a destroyable instance.
Use lower IDs, the more numbers you put, the more memory they take ( You can ignore this since it doesn’t impact that much)
Don’t form many connections on a single signal(it will take more time to loop through them)
Use DisconnectAll() on signals that you want to clear the connections of but still need it.
FAQ
Why use it over other signal-handling systems?
FLEXSignal is the most performant system that doesn’t rely on bindableEvents. It uses a cache-based system to lower down the memory collection as much as possible. In comparison to FastSignal, it is fast. You can verify that by going to the Update V1.1 post.
Is it fast?
FLEXSignals is reasonably fast if you don’t overload a signal with tons of connections that preforms complex jobs; at the most of the time, FLEXSignals doesn’t struggle really.
Do Server-made signal replicate with the client if the modulescript is placed in a replicated storage container?
Yes they do; meaning that clients can perform server-made connections but that’s will be only for them.
That’s it. I am more than happy to receive criticism or any suggestion that will improve the system.