NativeSignal:Connect Synchronous

Subscribe to a Kawaii runtime event such as WebSocket.OnMessage. Keep the returned connection if you may need to unsubscribe before the event source closes.

Syntax
Luau
NativeSignal:Connect(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 that receives the event’s arguments.

Returns

RBXScriptConnection

An RBXScriptConnection with Disconnect.

Usage notes

NativeSignal is provided by an owning API; it is not created with Signal.new. The event source determines what arguments the callback receives.

Example

Example
Luau
local socket = WebSocket.connect("wss://echo.websocket.events")
local listener = socket.OnMessage:Connect(function(message)
    print("Received:", message)
end)
socket:Send("hello")
task.wait(2)
listener:Disconnect()
socket:Close()
Kawaii documentation