RealSignal

RealSignal.Wait

Yields the current thread until the RealSignal is fired, then resumes with the arguments passed to Fire.

ไวยากรณ์

RealSignal.Wait(signal: RealSignal): ....any

Arguments

ชื่อชนิดคำอธิบาย
signalRealSignalSignal object returned by Signal.new.

Returns

ชื่อชนิดคำอธิบาย
...values....anyAll 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.

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

ส่งคืน ...values (....any) ใช้ตาราง returns เพื่อแยกค่าที่สำเร็จ ผลลัพธ์ nil และ error ที่จัดการต่อได้

ตัวอย่าง

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)

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.