Signal:Once Synchronous

  • KawaiiSignal:Once
  • PsmSignal:Once
  • VoltSignal: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.

Syntax
Luau
Signal:Once(callback: Function) -> SignalConnection

Parameters

Call this method with a Signal receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.

Function parameters
ParameterTypeDescription
callbackFunctionFunction called with the arguments from the next signal firing.

Returns

SignalConnection

A SignalConnection that can also be disconnected before its first event.

SignalConnection fields
Luau
SignalConnection = {Connected: boolean, Disconnect: Function}

Example

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()
Kawaii documentation