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

ConnectionHandler

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

Code Example

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