语法
Signal.new(): RealSignal返回值
| 名称 | 类型 | 描述 |
|---|---|---|
signal | RealSignal | New signal object with its own connection and waiter lists. |
说明
Creates a new RealSignal object. The returned signal exposes Connect, Once, Wait, and Fire methods.
无需参数即可调用。函数会从当前 runtime 状态读取所需上下文。
返回 signal (RealSignal)。使用返回表区分成功值、nil 结果和可恢复错误。
示例
Create an independent RealSignal and fire it with values.
local signal = Signal.new()
signal:Connect(function(value)
print(value)
end)
signal:Fire("ready")类型
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.