Signal

Create custom signals, connect callbacks and fire events.

6 functionssUNC 100%Lynx 0.0.0

Create custom events for communication between your scripts.

Creating signals

Signal.new

Signal.new(): Signal

Signal.new creates a custom signal.

Returns

Signal

The new signal.

Signal:Connect

Signal:Connect(callback: (...any) -> ()): SignalConnection

Signal:Connect connects a function to the signal.

Parameters

callback(...any) -> ()
The function to call when the signal fires.

Returns

SignalConnection

A connection that can be disconnected.

Signal:Once

Signal:Once(callback: (...any) -> ()): SignalConnection

Signal:Once connects a function that runs only the next time the signal fires.

Parameters

callback(...any) -> ()
The function to call when the signal fires.

Returns

SignalConnection

A connection that disconnects after one event.

Signal:Wait

Yields
Signal:Wait(): ...any

Signal:Wait waits for the signal to fire and returns the values passed to it.

Returns

...any

The arguments from the next signal event.

Signal:Fire

Signal:Fire(...any): ()

Signal:Fire fires the signal with the supplied values.

Parameters

......any
Arguments passed to the callback or signal.

Returns

()

This function does not return a value.

SignalConnection:Disconnect

SignalConnection:Disconnect(): ()

SignalConnection:Disconnect disconnects a callback from its custom signal.

Returns

()

This function does not return a value.

local signal = Signal.new()
local connection = signal:Connect(function(value)
print("received", value)
end)
signal:Fire("hello")
connection:Disconnect()