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.
function onConnected(handler: function): void;
handler(): void
The name of the function or
the function expression to run when a connection occurs.
import wixRealtimeFrontend from "wix-realtime-frontend";
// ...
wixRealtimeFrontend.onConnected(() => {
// handle connection
$w("#disconnectedMessage").hide();
});
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.