Składnia
RealSignal.Connect(signal: RealSignal, callback: (....any) -> ()): RealSignalConnectionArgumenty
| Nazwa | Typ | Opis |
|---|---|---|
signal | RealSignal | Signal object returned by Signal.new. |
callback | (....any) -> () | Function called whenever the signal is fired while the connection remains connected. |
Zwroty
| Nazwa | Typ | Opis |
|---|---|---|
connection | RealSignalConnection | Connection object with Disconnect. |
Opis
Connects a callback to a RealSignal and returns a RealSignalConnection. The callback receives the arguments passed to Fire.
Wywolaj z 2 parametrami: signal, callback. Tabela argumentow wyjasnia wartosci wymagane i te, ktore doprecyzowuja zachowanie.
Zwraca connection (RealSignalConnection). Uzyj tabeli zwrotow, aby oddzielic wartosci sukcesu, wyniki nil i bledy do obsluzenia.
Przykład
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()Typy
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.