문법
RealSignal.Connect(signal: RealSignal, callback: (....any) -> ()): RealSignalConnection인수
| 이름 | 타입 | 설명 |
|---|---|---|
signal | RealSignal | Signal object returned by Signal.new. |
callback | (....any) -> () | Function called whenever the signal is fired while the connection remains connected. |
반환값
| 이름 | 타입 | 설명 |
|---|---|---|
connection | RealSignalConnection | Connection object with Disconnect. |
설명
Connects a callback to a RealSignal and returns a RealSignalConnection. The callback receives the arguments passed to Fire.
2개 파라미터로 호출합니다: signal, callback. 인수 표는 필수 값과 동작을 조정하는 값을 설명합니다.
connection (RealSignalConnection)을 반환합니다. 반환 표를 사용해 성공 값, nil 결과, 복구 가능한 오류를 구분하세요.
예제
Connect a callback and disconnect it when it is no longer needed.
local signal = Signal.new()
local connection = signal:Connect(function(value)
print(value)
end)
signal:Fire(1)
connection:Disconnect()타입
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.RealSignalConnection
Connection object returned by RealSignal.Connect and RealSignal.Once.
Disconnect () -> () Disconnects the connection.