Signal utilities
A alternative of BindableEvent.
.Signal
Create new Signal.
lua
(
Identifier: string
)
lua
local Signal1 = Warp.Signal("Signal1")
.fromSignalArray
Create new Signal.
lua
(
{ string }
)
lua
local Signals = Warp.fromSignalArray({"Signal1", "Signal2"})
Signals.Signal1:Connect(function(...) end)
Signals.Signal2:Connect(function(...) end)
:Connect
lua
(
callback: (...any) -> ()
)
lua
Signal1:Connect(function(...)
print(...)
end)
:Once
This function likely :Connect
but it disconnect the signal once it fired.
lua
(
callback: (...any) -> ()
)
lua
Signal1:Once(function(...)
print(...)
end)
:Disconnect
Disconnect the signal connection.
lua
(
key: string
)
lua
local connection = Signal1:Connect(function(...) end) -- store the key
Signal1:Disconnect(connection)
WARNING
This requires key
to disconnect a signal connection.
:DisconnectAll
Disconnect All signal connections.
lua
Signal1:DisconnectAll()
:Fire
Fire the signal (Immediate)
lua
(
...: any
)
lua
Signal1:Fire("Hello World!")
:DeferFire
Fire the signal (Deferred)
lua
(
...: any
)
lua
Signal1:Fire("Hello World!")
WARNING
This uses pcall
, which means it never error (safe-mode, sacrificed debugging), But gains performance here (upto 5x faster)
.
:FireTo
Fire to other signal, this uses :Fire
.
lua
(
signal: string,
...: any
)
lua
Signals.Signal1:FireTo("Signal2", "Hello World!")
WARNING
This requires key
.
:Invoke
yield
lua
(
key: string,
...: any
) -> (...any)
lua
local connection = Signal1:Conenct(function(...) return "hey!" end)
local Request = Signal1:Invoke(connection, "Hello World!")
:InvokeTo
yield
this use :Invoke
.
lua
(
signal: string,
key: string,
...: any
) -> (...any)
lua
local connection2 = Signals.Signal2:Conenct(function(...) return "hey!" end)
local Request = Signals.Signal1:Invoke("Signal2", connection2, "Hello World!")
WARNING
This requires key
.
:Wait
yield
Wait the signal get triggered.
lua
Signal1:Wait() -- return number (time)
WARNING
This function is yielded
:Destroy
Disconnect all connection of signal and remove the signal from Signals
lua
Signal1:Destroy()