VoltSignal:Once

Connects a handler that disconnects itself after the signal fires once.

Syntax

VoltSignal:Once(f: function) -> VoltConnection

Parameters

ParameterTypeDescription
ffunctionHandler to invoke on the next fire

Returns

TypeDescription
VoltConnectionThe one-shot connection

Description

VoltSignal:Once behaves like Connect, but automatically disconnects the handler after its first invocation.

Example

local signal = VoltSignal.new()

local connection = signal:Once(function(value)
    print("Received:", value)
end)

signal:Fire("first")  -- Received: first
signal:Fire("second") -- No output
print(connection.Connected) -- false