disconnect event not emitted and confirmation box not appearing on timeout [angular]

31 views Asked by At

in component A:

``idle.onTimeout.subscribe(() => {
      this.SharedService.isDisconnected.emit(true);
      if(confirm('OK to refresh Cancel to Logout')){
      this.route.navigate(['home/']);
      document.location.reload();}
      else{ this.msalService.logout();}
      });``

in signal-r component, the Disconnect method is written.

`` ngOnInit(){
      this.SharedService.isDisconnected$.subscribe((isDisconnect) => {
      if(isDisconnect)
      {this.Disconnect();}}

      public Disconnect(){
      this.proxy.invoke('DeleteConnectID', this.currentConnectionID);
      }
      ``

in shared-service.ts, ``

public isDisconnected = new BehaviorSubject<boolean>(false);
   public isDisconnected$ = this.isDisconnected.asObservable();
 ``

in componentA, on timeout,the session is going to disconnect immediately, and the confirmation box appears for asking to refresh or logout the user. This popup is not coming intermittently for sometimes, and the disconnect is also not invoked sometimes. what is the solution anyone knows please share, thanks! instead of confirm() dialogRef can be used? does that always works as expected?

0

There are 0 answers