Signal
Signal (an alternative for bindable events)
.Signal
Create new Signal event
lua
(
Identifier: string
)
(
Identifier: string
)
lua
local Signal = FastNet2.Signal("TestSignal")
local Signal = FastNet2.Signal("TestSignal")
:Connect
Listen an event to signal.
lua
(
callback: (...any) -> ()
)
(
callback: (...any) -> ()
)
lua
Signal:Connect(function(...)
print(...)
end)
Signal:Connect(function(...)
print(...)
end)
lua
-- to know if the signal is connected or not by doing `.Connected`
print(Signal.Connected)
-- to know if the signal is connected or not by doing `.Connected`
print(Signal.Connected)
Each signal event only allowed have one callback.
:Once
This function is same as :Connect
but it disconnect the signal once it fired.
lua
(
callback: (...any) -> ()
)
(
callback: (...any) -> ()
)
lua
Signal:Once(function(...)
print(...)
end)
Signal:Once(function(...)
print(...)
end)
:Disconnect
Disconnect the signal
lua
Signal:Disconnect()
Signal:Disconnect()
:Fire
Fire the signal with data.
lua
(
...: any
)
(
...: any
)
lua
Signal:Fire("Hello World!")
Signal:Fire("Hello World!")
:Invoke
Invoke is a function that invoke to signal.
lua
(
timeout: number,
...: any
) -> (...any)
(
timeout: number,
...: any
) -> (...any)
lua
local Request = Signal:Invoke(2, "Hello World!")
local Request = Signal:Invoke(2, "Hello World!")
WARNING
This function is yielded
:Wait
Wait the signal that triggered/pinged
lua
Signal:Wait()
Signal:Wait()
WARNING
This function is yielded
:Destroy
Disconnect the signal and remove the signal
lua
Signal:Destroy()
Signal:Destroy()