構文
RealSignal.Once(signal: RealSignal, callback: (....any) -> ()): RealSignalConnection引数
| 名前 | 型 | 説明 |
|---|---|---|
signal | RealSignal | Signal object returned by Signal.new. |
callback | (....any) -> () | Function called at most once for this connection. |
戻り値
| 名前 | 型 | 説明 |
|---|---|---|
connection | RealSignalConnection | Connection object with Disconnect. |
説明
Connects a callback that is disconnected before its first callback invocation. The callback receives the arguments passed to Fire.
2 個のパラメータで呼び出します: signal, callback。引数表では必須値と動作を調整する値を確認できます。
connection (RealSignalConnection) を返します。戻り値表を使って成功値、nil 結果、回復可能なエラーを分けて扱ってください。
例
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")型
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.