RealSignal

Signal.new

Creates a new RealSignal object.

ไวยากรณ์

Signal.new(): RealSignal

Returns

ชื่อชนิดคำอธิบาย
signalRealSignalNew signal object with its own connection and waiter lists.

คำอธิบาย

Creates a new RealSignal object. The returned signal exposes Connect, Once, Wait, and Fire methods.

เรียกโดยไม่ต้องมี parameter ฟังก์ชันอ่าน context ที่ต้องใช้จาก runtime state ปัจจุบัน

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

ตัวอย่าง

Create an independent RealSignal and fire it with values.

local signal = Signal.new()

signal:Connect(function(value)
    print(value)
end)

signal:Fire("ready")

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.