ngIdle - How to clear and reset interrupts in Angu

2020-05-04 13:34发布

I have integrated ngidle library in my app and i am showing dialog with timeout value . I would like to stop the timer value only on interactions on the dialog . not on the screen so on nginit i have set the default interrrupts and on timeout warning i am clearing the interrupts but i am not able to reset the interrupts .

The sample code is below , Please check and let me know if anything goes wrong .

 ngOnInit() {

// sets the default interrupts, in this case, things like clicks, scrolls, touches to the document
this.idle.setInterrupts(DEFAULT_INTERRUPTSOURCES);
  }

this.idle.onTimeoutWarning.subscribe((countdown) => {

  this.idle.clearInterrupts();
  console.log('count down value' + countdown);
  this.dataService.changeVersionSelectionData(countdown);

});

this.idle.onIdleEnd.subscribe(() => {

  this.idle.setInterrupts(DEFAULT_INTERRUPTSOURCES);

});

0条回答
登录 后发表回答