@@ -196,9 +196,7 @@ class SignalRService {
196196 // Set up event handlers
197197 connection . onclose ( ( error ) => {
198198 this . handleConnectionClose ( config . name ) ;
199- if ( error ) {
200- this . notifyConnectionStateCallbacks ( config . name , 'onError' , error ) ;
201- }
199+ this . notifyConnectionError ( config . name , error ) ;
202200 this . notifyConnectionStateCallbacks ( config . name , 'onClose' ) ;
203201 } ) ;
204202
@@ -207,9 +205,7 @@ class SignalRService {
207205 message : `Reconnecting to hub: ${ config . name } ` ,
208206 context : { error } ,
209207 } ) ;
210- if ( error ) {
211- this . notifyConnectionStateCallbacks ( config . name , 'onError' , error ) ;
212- }
208+ this . notifyConnectionError ( config . name , error ) ;
213209 this . notifyConnectionStateCallbacks ( config . name , 'onReconnecting' ) ;
214210 } ) ;
215211
@@ -332,9 +328,7 @@ class SignalRService {
332328 // Set up event handlers
333329 connection . onclose ( ( error ) => {
334330 this . handleConnectionClose ( config . name ) ;
335- if ( error ) {
336- this . notifyConnectionStateCallbacks ( config . name , 'onError' , error ) ;
337- }
331+ this . notifyConnectionError ( config . name , error ) ;
338332 this . notifyConnectionStateCallbacks ( config . name , 'onClose' ) ;
339333 } ) ;
340334
@@ -343,9 +337,7 @@ class SignalRService {
343337 message : `Reconnecting to hub: ${ config . name } ` ,
344338 context : { error } ,
345339 } ) ;
346- if ( error ) {
347- this . notifyConnectionStateCallbacks ( config . name , 'onError' , error ) ;
348- }
340+ this . notifyConnectionError ( config . name , error ) ;
349341 this . notifyConnectionStateCallbacks ( config . name , 'onReconnecting' ) ;
350342 } ) ;
351343
@@ -645,6 +637,12 @@ class SignalRService {
645637 }
646638 }
647639
640+ private notifyConnectionError ( hubName : string , error ?: Error ) : void {
641+ if ( error ) {
642+ this . notifyConnectionStateCallbacks ( hubName , 'onError' , error ) ;
643+ }
644+ }
645+
648646 private notifyConnectionStateCallbacks ( hubName : string , event : keyof SignalRConnectionStateCallbacks , error ?: Error ) : void {
649647 this . connectionStateCallbacks . get ( hubName ) ?. forEach ( ( callbacks ) => {
650648 try {
0 commit comments