语法
RealSignal.Wait(signal: RealSignal): ....any参数
| 名称 | 类型 | 描述 |
|---|---|---|
signal | RealSignal | Signal object returned by Signal.new. |
返回值
| 名称 | 类型 | 描述 |
|---|---|---|
...values | ....any | All values passed to the Fire call that resumed the waiter. |
说明
Yields the current thread until the RealSignal is fired, then resumes with the arguments passed to Fire. It errors when called from a context that cannot yield.
使用 1 个参数调用: signal。参数表会说明哪些值必填,哪些值只用于细化行为。
返回 ...values (....any)。使用返回表区分成功值、nil 结果和可恢复错误。
示例
Yield until the signal fires and receive the fired values.
local signal = Signal.new()
task.spawn(function()
task.wait(1)
signal:Fire("done", 2)
end)
local status, count = signal:Wait()
print(status, count)类型
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.