in that case you can listen the dialog close and start the timer in case of necessary
openTimeOutDialog(){
setTimeout (()=>{this.logoutService.logout();}, time);
this.dialog.open(
timeoutDialog,
{width: '500px'}
)
.afterClosed()
.subsribe(
response => { if(response.startSession) {this. setSessionTimer() } }
)
}
where the response of afterClosed
meethod comes from the dialog
like this
Modal.component.ts
export class ModalComponent implements OnInit {
constructor(
public modalRef: MatDialogRef<ModalComponent, ModalOutputData>,
@Inject(MAT_DIALOG_DATA) public data: DefaultModalInputData
) { }
ngOnInit() {
console.log(this.data, 'data');
}
/**
* close dialog and continue
*
* @param null
*
* @return `void`
*/
onContinue() {
this.modalRef.close({ startSession: true });
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…