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.
handler(): void The name of the function or the function expression to run when a connection occurs.