VoltSignal:Wait
Yields the current thread until the signal fires.
Syntax
VoltSignal:Wait() -> anyParameters
This method takes no parameters.
Returns
| Type | Description |
|---|---|
any | The arguments passed to Fire |
Description
VoltSignal:Wait pauses the current thread until the signal is fired. When the signal fires, the thread resumes and returns any arguments that were passed to Fire.
This method has no built-in timeout.
Example
local signal = VoltSignal.new()
-- In another thread, fire after 2 seconds
task.spawn(function()
task.wait(2)
signal:Fire("Data loaded!", 100)
end)
-- Wait for the signal
local message, value = signal:Wait()
print(message, value)
-- Output (after 2 seconds): Data loaded! 100Related Functions
VoltSignal:Fire- Fire the signalVoltSignal:Connect- Connect without yielding