Skip to content

Commit

Permalink
Merge pull request #20 from Ranvier-TS/fix-tick-interval-usage
Browse files Browse the repository at this point in the history
Fix tickInterval
  • Loading branch information
seanohue authored Jun 17, 2021
2 parents 999ab3c + ed08067 commit 277dd67
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/EffectList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,18 @@ export class EffectList {
typeof effect.config.tickInterval !== 'undefined'
) {
const now = Date.now();
const sinceLastTick = now - effect.state.lastTick;
if (
Date.now() <
effect.state.ticks * effect.config.tickInterval * 1000
sinceLastTick <
effect.config.tickInterval * 1000
) {
continue;
}
effect.state.lastTick = now;
effect.state.ticks && effect.state.ticks++;
if (!effect.state.ticks && effect.state.ticks !== 0) {
effect.state.ticks = 0;
}
effect.state.ticks++;
}
(effect as Effect).emit(event, ...args);
}
Expand Down

0 comments on commit 277dd67

Please sign in to comment.