Signal: Once Synchronous
KawaiiSignal:OncePsmSignal:OnceVoltSignal:Once
Register a callback that is disconnected when it receives its first event. Use it for a one-time notification, such as the first successful import. Further events do not call that listener again.
Luau
Signal:Once(callback: Function) -> SignalConnectionParameters
Call this method with a Signal receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.
| Parameter | Type | Description |
|---|---|---|
callback | Function | Function called with the arguments from the next signal firing. |
Returns
SignalConnectionA SignalConnection that can also be disconnected before its first event.
Luau
SignalConnection = {Connected: boolean, Disconnect: Function}Example
Luau
local imported = Signal.new()
imported:Once(function(name)
print("First import:", name)
end)
imported:Fire("settings.json")
imported:Fire("colors.json") -- the one-time listener is no longer connected
imported:Destroy()