Skip to content

Commit

Permalink
Change names back
Browse files Browse the repository at this point in the history
  • Loading branch information
afshin committed Sep 27, 2022
1 parent b29e1a0 commit 4ed8402
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/polling/src/poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class Poll<T = any, U = any, V extends string = 'standby'>
this.name = options.name || Private.DEFAULT_NAME;

if ('auto' in options ? options.auto : true) {
setTimeout(() => void this.start(), 0);
setTimeout(() => this.start());
}
}

Expand Down Expand Up @@ -211,12 +211,9 @@ export class Poll<T = any, U = any, V extends string = 'standby'>
return;
}

// Clear the schedule if possible.
clearTimeout(this._scheduled);

// Update poll state.
const pending = this._tick;
const tick = new PromiseDelegate<this>();
const scheduled = new PromiseDelegate<this>();
const state = {
interval: this.frequency.interval,
payload: null,
Expand All @@ -225,7 +222,10 @@ export class Poll<T = any, U = any, V extends string = 'standby'>
...next
} as IPoll.State<T, U, V>;
this._state = state;
this._tick = tick;
this._tick = scheduled;

// Clear the schedule if possible.
clearTimeout(this._scheduled);

// Emit ticked signal, resolve pending promise, and await its settlement.
this._ticked.emit(this.state);
Expand All @@ -234,7 +234,7 @@ export class Poll<T = any, U = any, V extends string = 'standby'>

// Schedule next execution and cache its timeout handle.
const execute = () => {
if (this.isDisposed || this.tick !== tick.promise) {
if (this.isDisposed || this.tick !== scheduled.promise) {
return;
}

Expand Down

0 comments on commit 4ed8402

Please sign in to comment.