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