onConnected( )


Adds an event handler that runs when a connection or reconnection occurs.

A connection occurs on the first subscription to a channel or channel resource or when an existing connection is lost and then restored.

Method Declaration
Copy
function onConnected(handler: function): void;
Method Parameters
handlerfunctionRequired

handler(): void The name of the function or the function expression to run when a connection occurs.

Add a connection handler
JavaScript
import wixRealtimeFrontend from "wix-realtime-frontend"; // ... wixRealtimeFrontend.onConnected(() => { // handle connection $w("#disconnectedMessage").hide(); });
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?