Syntax
RealSignal.Once(signal: RealSignal, callback: (....any) -> ()): RealSignalConnectionArguments
| Name | Type | Description |
|---|---|---|
signal | RealSignal | Signal object returned by Signal.new. |
callback | (....any) -> () | Function called at most once for this connection. |
Returns
| Name | Type | Description |
|---|---|---|
connection | RealSignalConnection | Connection object with Disconnect. |
Description
Connects a callback that is disconnected before its first callback invocation. The callback receives the arguments passed to Fire.
Call it with 2 parameter(s): signal, callback. The argument table explains which values are required and which ones only refine the behavior.
It returns connection (RealSignalConnection). Use the returns table to separate successful values from nil results and recoverable errors.
Example
Connect a callback that runs at most once.
local signal = Signal.new()
signal:Once(function(value)
print(value)
end)
signal:Fire("first")
signal:Fire("second")Types
RealSignal
Signal object returned by Signal.new.
Connect (callback: (...any) -> ()) -> RealSignalConnection Adds a callback that runs when Fire is called.Once (callback: (...any) -> ()) -> RealSignalConnection Adds a callback that is disconnected before its first callback invocation.Wait () -> ...any Yields until Fire resumes the waiter with the fired values.Fire (...values: any) -> () Runs connected callbacks and resumes waiters with the provided values.RealSignalConnection
Connection object returned by RealSignal.Connect and RealSignal.Once.
Disconnect () -> () Disconnects the connection.