NativeSignal: Once Synchronous
Listen for the next event from a Kawaii runtime signal and then disconnect automatically. This works well for a single reply or close notification.
Luau
NativeSignal:Once(callback: Function) -> RBXScriptConnectionParameters
Call this method with a NativeSignal receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.
| Parameter | Type | Description |
|---|---|---|
callback | Function | Function called with the next event’s arguments. |
Returns
RBXScriptConnectionAn RBXScriptConnection that can be disconnected earlier.
Usage notes
The event source determines the callback arguments. Like Connect, this method does not create or own the event source.
Example
Luau
local socket = WebSocket.connect("wss://echo.websocket.events")
socket.OnMessage:Once(function(message)
print("First reply:", message)
end)
socket:Send("one reply")
task.wait(2)
socket:Close()