Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
maxima-net committed Sep 5, 2022
1 parent 880432a commit 2cf471a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/core/timeoutScheduler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Disposable } from '../common';

export class TimeoutScheduler implements Disposable {
private actionCounter = 0;
private counter = 0;
private counterExpirationWatcherId: ReturnType<typeof setTimeout> | undefined;
private actionWatcherId: ReturnType<typeof setTimeout> | undefined;

Expand All @@ -22,15 +22,15 @@ export class TimeoutScheduler implements Disposable {
if (this.counterExpirationMs)
this.resetCounterExpiration();

const timeoutIndex = Math.min(this.actionCounter, this.timeouts.length - 1);
const timeoutIndex = Math.min(this.counter, this.timeouts.length - 1);
const timeout = this.timeouts[timeoutIndex];
this.actionWatcherId = setTimeout(action, timeout);

this.actionCounter++;
this.counter++;
}

resetCounter() {
this.actionCounter = 0;
this.counter = 0;
}

private resetCounterExpiration() {
Expand Down

0 comments on commit 2cf471a

Please sign in to comment.