RealSignal

RealSignal.Fire

Fires the RealSignal with zero or more values.

ไวยากรณ์

RealSignal.Fire(signal: RealSignal, ...values?: ....any)

Arguments

ชื่อชนิดคำอธิบาย
signalRealSignalSignal object returned by Signal.new.
...values?....anyValues 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.

เรียกด้วย parameter 2 ค่า: signal, ...values ตาราง arguments อธิบายค่าที่จำเป็นและค่าที่ปรับพฤติกรรม

ไม่ส่งคืนข้อมูล ให้มอง call นี้เป็น action และจัดการ error รอบจุดที่เรียกเมื่อจำเป็น

ตัวอย่าง

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)

Types

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.