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.

Syntax
Luau
NativeSignal:Once(callback: Function) -> RBXScriptConnection

Parameters

Call this method with a NativeSignal receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.

Function parameters
ParameterTypeDescription
callbackFunctionFunction called with the next event’s arguments.

Returns

RBXScriptConnection

An 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

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()
Kawaii documentation