[Vuejs]-Idle timer within Vue Component

1๐Ÿ‘

โœ…

I thought clearInterval should reset the timer?

Do you mean this.remainingTimeoutSeconds is set automatically when calling clearInterval?

The answer is no.

You need to reset that value as 10000 like blow;

handleContinueButtonClick(response) {
  if (response.data.success) {
      console.log("IN")
      this.$bvModal.hide('app-timeout-reminder-modal');
      this.remainingTimeoutSeconds = 10000;
      clearInterval(this.timerId);
      return;
  }
}

or

showWarningMessage() {
  this.$bvModal.show('timeout-modal');
  this.warning = true;
  this.remainingTimeoutSeconds = 10000;

  this.timerId = setInterval(() => {
    this.remainingTimeoutSeconds -= 1000;
  }, 1000);
}
๐Ÿ‘คDiamond

Leave a comment