语法
RealSignal.Fire(signal: RealSignal, ...values?: ....any)参数
| 名称 | 类型 | 描述 |
|---|---|---|
signal | RealSignal | Signal object returned by Signal.new. |
...values? | ....any | Values forwarded to connected callbacks and waiting threads. |
说明
Fires the RealSignal with zero or more values. Connected callbacks receive those values, once connections are disconnected before invocation, and waiting threads are resumed with the same values. The method returns no values.
使用 2 个参数调用: signal, ...values。参数表会说明哪些值必填,哪些值只用于细化行为。
不返回数据。将调用视为一个动作,并在调用点附近处理错误。
示例
Forward values to connected callbacks and waiting threads.
local signal = Signal.new()
local total = 0
signal:Connect(function(value)
total += value
end)
signal:Fire(5)
print(total)类型
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.