Search.../

onConnected( )

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

Description

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

Syntax

function onConnected(handler: ConnectionHandler): void
handler: function ConnectionHandler(): void

onConnected Parameters

NAME
TYPE
DESCRIPTION
handler

The name of the function or the function expression to run when a connection occurs.

Returns

This function does not return anything.

Return Type:

void

ConnectionHandler Parameters

This function does not take any parameters.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

Add a connection handler

Copy Code
1import wixRealtimeFrontend from 'wix-realtime-frontend';
2
3// ...
4
5wixRealtimeFrontend.onConnected( () => {
6 // handle connection
7 $w("#disconnectedMessage").hide();
8} );