Releases: AlternativeLua/SuphisSignalModule
v1.0
Version: 0.5 [BETA]
Update
- you can now pass custom arguments into Connect, Once and Wait that will be past to the function when called
Version: 0.4 [BETA]
SuphisSignalModule
This is not my module it's Suphi#3388 module, join the discord here: https://discord.gg/B3zmjPVBce
Features
- No Parameter Limitations: Unlike ROBLOX Events there are no parameter limitations
- Fast: Look at benchmarks below
- Table Reference: Passing a table will pass a refrence and does not deep clone the table
- Fire In Order: Events are fired in the same order they where connected in
- Familiar: Works a lot like RBXScriptSignal and RBXScriptConnection
Benchmarks
| Method | FastSignal | SuphisSignal | GoodSignal | SimpleSignal | RobloxSignal |
|---|---|---|---|---|---|
New |
0.2 | 0.3 | 0.2 | 0.1 | 1.1 |
Connect |
0.5 | 1.0 | 0.4 | 0.3 | 2.3 |
Disconnect |
0.1 | 0.5 | 139.8 | 3.8 | 39.0 |
Fire |
2.0 | 46.8 & 3.7 | 31.3 | 104.8 | 30.6 |
Wait |
3.5 | 3.5 | 3.9 | 5.3 | 5.4 |
Download the benchmark ->
https://discord.com/channels/909926338801061961/1042810934277713931/1046079394042609824
microseconds to complete (lower is better)
Fire is the most important benchmark as that's what your going to be doing the most
SuphisSignal vs FastSignal
FastSignal does not create new threads when it fires connections this makes FastSignal fast but if any of the connections use async functions or task.wait() it will block the next connections from fireing until the current connection has finished SuphisSignal has a method called FastFire that works like FastSignal
#SuphisSignal vs Good Signal
SuphisSignal works a lot like GoodSignal but with some small differences
- GoodSignal only caches 1 thread where SuphisSignal caches 16 threads it creates
- GoodSignal and SuphisSignal both use linked lists but SuphisSignal uses doubly linked list this allows SuphisSignal to disconnect connections without traversing the list
- GoodSignal new connections are added to the front of the list making connections fire in reverse order SuphisSignal adds new connections to the end of the list making them fire in the same order as they where connected
Download
Go to release and get the prefered version. or
local signalModule = require(11670710927)Current Version: Version: 0.4 [BETA]
Constructors
SIGNAL MODULE
new()
Returns a new signal object
Methods
SIGNAL OBJECT
Connect(unc: function) connectionConnects the given function to the event and returns an connection that represents it
Once(func: function) connectionConnects the given function to the event (for a single invocation) and returns an connection that represents it
Wait() TupleYields the current thread until the signal fires and returns the arguments provided by the signal
DisconnectAll() nilDisconnects all connections from the signal
Fire(arguments: Tuple) nilFires the event
Properties
CONNECTION OBJECT
Signal signal/nil "signal" READ ONLYThe signal object this connection is connected to or nil
METHODS
Disconnect() nilDisconnects the connection from the signal
Simple Example
-- Require the ModuleScript
local signalModule = require(11670710927)
-- create a signal object
local signal = signalModule.new()
-- connect a function to the signal
local connection = signal:Connect(function(...)
print(...)
end)
-- fire the signal
signal:Fire("Hello world!")
-- Disconnect the connection from the signal
connection:Disconnect()Disconnect All example
local signalModule = require(11670710927)
local signal = signalModule.new()
signal:Connect(function(...) print("Conection1", ...) end)
signal:Connect(function(...) print("Conection2", ...) end)
signal:Connect(function(...) print("Conection3", ...) end)
signal:Fire("Hello world!")
-- Disconnect all connections from the signal
signal:DisconnectAll()
-- fire the signal again this time nothing will print to output because we disconnected all connections
signal:Fire("Hello world!")Once Example
local signalModule = require(11670710927)
local signal = signalModule.new()
-- connection a function to only be called once
signal:Once(function(...) print(...) end)
signal:Fire("Hello world!")
-- fire the signal again this time nothing will print to output because once will automatically disconnect once it gets fired
signal:Fire("Hello world!")Wait Example
local signalModule = require(11670710927)
local signal = signalModule.new()
-- fire after a 10 second delay
task.delay(10, signal.Fire, signal, "Hello world!")
-- wait for the signal to fire then print it
print(signal:Wait())Version: 0.3 [BETA]
SuphisSignalModule
This is not my module it's Suphi#3388 module, join the discord here: https://discord.gg/B3zmjPVBce
Features
No Parameter Limitations Unlike ROBLOX Events there are no parameter limitations
Fast Look at benchmarks below
Table Reference Passing a table will pass a refrence and does not deep clone the table
Fire In Order Events are fired in the same order they where connected in
Familiar Works a lot like RBXScriptSignal and RBXScriptConnection
| FastSignal | SuphisSignal | GoodSignal | SimpleSignal | RobloxSignal |
New
| 0.2 | 0.5 | 0.2 | 0.1 | 2.8 |
Connect
| 1.0 | 1.9 | 0.8 | 0.6 | 5.2 |
Disconnect
| 0.2 | 1.2 | 138.3 | 5.7 | 41.5 |
Fire
| 6.0 | 49.1 | 46.9 | 113.0 | 34.0 |
Wait
| 4.2 | 5.0 | 5.5 | 7.9 | 7.3 |
microseconds to complete (lower is better)
Fire is the most important benchmark as that's what your going to be doing the most
SuphisSignal vs FastSignal
FastSignal does not create new threads when it fires connections this makes FastSignal fast but if any of the connections use async functions or task.wait() it will block the next connections from fireing until the current connection has finished
#SuphisSignal vs Good Signal
SuphisSignal works a lot like GoodSignal but with some small differences
- GoodSignal only caches 1 thread where SuphisSignal caches all threads it creates
- GoodSignal and SuphisSignal both use linked lists but SuphisSignal uses doubly linked list this allows SuphisSignal to disconnect connections without traversing the list
- GoodSignal new connections are added to the front of the list making connections fire in reverse order SuphisSignal adds new connections to the end of the list making them fire in the same order as they where connected
Download
Go to release and get the prefered version. or
local signalModule = require(11670710927)Current Version: Version: 0.3 [BETA]
Constructors
new()
Returns a new signal object
Methods
Connect(unc: function) connectionConnects the given function to the event and returns an connection that represents it
Once(func: function) connectionConnects the given function to the event (for a single invocation) and returns an connection that represents it
Wait() TupleYields the current thread until the signal fires and returns the arguments provided by the signal
DisconnectAll() nilDisconnects all connections from the signal
Fire(arguments: Tuple) nilFires the event
Properties
Signal signal/nil "signal" READ ONLYThe signal object this connection is connected to or nil
Methods
Disconnect() nilDisconnects the connection from the signal
Simple Example
-- Require the ModuleScript
local signalModule = require(11670710927)
-- create a signal object
local signal = signalModule.new()
-- connect a function to the signal
local connection = signal:Connect(function(...)
print(...)
end)
-- fire the signal
signal:Fire("Hello world!")
-- Disconnect the connection from the signal
connection:Disconnect()Disconnect All example
local signalModule = require(11670710927)
local signal = signalModule.new()
signal:Connect(function(...) print("Conection1", ...) end)
signal:Connect(function(...) print("Conection2", ...) end)
signal:Connect(function(...) print("Conection3", ...) end)
signal:Fire("Hello world!")
-- Disconnect all connections from the signal
signal:DisconnectAll()
-- fire the signal again this time nothing will print to output because we disconnected all connections
signal:Fire("Hello world!")Once Example
local signalModule = require(11670710927)
local signal = signalModule.new()
-- connection a function to only be called once
signal:Once(function(...) print(...) end)
signal:Fire("Hello world!")
-- fire the signal again this time nothing will print to output because once will automatically disconnect once it gets fired
signal:Fire("Hello world!")Wait Example
local signalModule = require(11670710927)
local signal = signalModule.new()
-- fire after a 10 second delay
task.delay(10, signal.Fire, signal, "Hello world!")
-- wait for the signal to fire then print it
print(signal:Wait())Version: 0.2 [BETA]
SuphisSignalModule
This is not my module it's Suphi#3388 module, join the discord here: https://discord.gg/B3zmjPVBce
Features
No Parameter Limitations Unlike ROBLOX Events there are no parameter limitations
Fast Look at benchmarks below
Table Reference Passing a table will pass a refrence and does not deep clone the table
Fire In Order Events are fired in the same order they where connected in
Familiar Works a lot like RBXScriptSignal and RBXScriptConnection
| FastSignal | GoodSignal | SimpleSignal | SuphisSignal | RobloxSignal |
New
| 0.1 | 0.5 | 0.2 | 0.3 | 2.6 |
Connect
| 0.4 | 0.5 | 1.0 | 0.6 | 3.1 |
Disconnect
| 0.2 | 148.5 | 3.8 | 0.9 | 41.7 |
Fire
| 4.1 | 48.7 | 114.9 | 18.0 | 34.0 |
Wait
| 4.5 | 5.0 | 6.1 | 3.3 | 6.0 |
microseconds to complete (lower is better)
Fire is the most important benchmark as that's what your going to be doing the most
Download
Go to release and get the prefered version.
Current Version: Version: 0.2 [BETA]
Constructors
new()
Returns a new signal object
Methods
Connect(unc: function) connectionConnects the given function to the event and returns an connection that represents it
Once(func: function) connectionConnects the given function to the event (for a single invocation) and returns an connection that represents it
Wait() TupleYields the current thread until the signal fires and returns the arguments provided by the signal
DisconnectAll() nilDisconnects all connections from the signal
Fire(arguments: Tuple) nilFires the event
Properties
Signal signal/nil "signal" READ ONLYThe signal object this connection is connected to or nil
Methods
Disconnect() nilDisconnects the connection from the signal
Simple Example
-- Require the ModuleScript
local signalModule = require(game.ServerStorage.SuphisSignalModule)
-- create a signal object
local signal = signalModule.new()
-- connect a function to the signal
local connection = signal:Connect(function(...)
print(...)
end)
-- fire the signal
signal:Fire("Hello world!")
-- Disconnect the connection from the signal
connection:Disconnect()Disconnect All example
local signalModule = require(game.ServerStorage.SuphisSignalModule)
local signal = signalModule.new()
signal:Connect(function(...) print("Conection1", ...) end)
signal:Connect(function(...) print("Conection2", ...) end)
signal:Connect(function(...) print("Conection3", ...) end)
signal:Fire("Hello world!")
-- Disconnect all connections from the signal
signal:DisconnectAll()
-- fire the signal again this time nothing will print to output because we disconnected all connections
signal:Fire("Hello world!")Once Example
local signalModule = require(game.ServerStorage.SuphisSignalModule)
local signal = signalModule.new()
-- connection a function to only be called once
signal:Once(function(...) print(...) end)
signal:Fire("Hello world!")
-- fire the signal again this time nothing will print to output because once will automatically disconnect once it gets fired
signal:Fire("Hello world!")Wait Example
local signalModule = require(game.ServerScriptService.Classes.DataStore.Signal)
local signal = signalModule.new()
-- fire after a 10 second delay
task.delay(10, signal.Fire, signal, "Hello world!")
-- wait for the signal to fire then print it
print(signal:Wait())Full Changelog: https://github.com/NameTakenBonk/SuphisSignalModule/commits/Beta