VoltSignal:Once
Connects a handler that disconnects itself after the signal fires once.
Syntax
VoltSignal:Once(f: function) -> VoltConnectionParameters
| Parameter | Type | Description |
|---|---|---|
f | function | Handler to invoke on the next fire |
Returns
| Type | Description |
|---|---|
VoltConnection | The 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