Signal
Create custom signals, connect callbacks and fire events.
Create custom events for communication between your scripts.
Creating signals
Signal.new
Signal.new(): SignalSignal.new creates a custom signal.
Returns
SignalThe new signal.
Signal:Connect
Signal:Connect(callback: (...any) -> ()): SignalConnectionSignal:Connect connects a function to the signal.
Parameters
callback(...any) -> ()- The function to call when the signal fires.
Returns
SignalConnectionA connection that can be disconnected.
Signal:Once
Signal:Once(callback: (...any) -> ()): SignalConnectionSignal: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
SignalConnectionA connection that disconnects after one event.
Signal:Wait
YieldsSignal:Wait(): ...anySignal:Wait waits for the signal to fire and returns the values passed to it.
Returns
...anyThe 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.
Written for Lynx 0.0.0
Something unclear? Tell us on Discord