Cú pháp
RealSignal.Fire(signal: RealSignal, ...values?: ....any)Đối số
| Tên | Kiểu | Mô tả |
|---|---|---|
signal | RealSignal | Signal object returned by Signal.new. |
...values? | ....any | Values forwarded to connected callbacks and waiting threads. |
Mô tả
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.
Goi voi 2 parameter: signal, ...values. Bang arguments giai thich gia tri nao bat buoc va gia tri nao chi tinh chinh hanh vi.
Khong tra ve du lieu. Xem call nhu mot action va xu ly loi quanh vi tri goi khi can.
Ví dụ
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)Kiểu
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.