Skip to content

Commit

Permalink
Enclose the delay generator inside replayMovesRepeater.
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoknjas committed Dec 12, 2024
1 parent 251393e commit 478ce8c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions ui/common/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,11 @@ export function myUserId(): string | undefined {
return document.body.dataset.user;
}

export function* showMovesDecreasingDelay(): Generator<number, void, void> {
yield 500;
for (let d = 350; ; ) yield Math.max(100, (d *= 14 / 15));
} // todo - make this inline in func below?

export function replayMovesRepeater(f: () => void, e: Event): void {
const delay = showMovesDecreasingDelay();
const delay = (function* () {
yield 500;
for (let d = 350; ; ) yield Math.max(100, d *= 14/15);
})();
const repeat = () => {
f();
timeout = setTimeout(repeat, delay.next().value!);
Expand Down

0 comments on commit 478ce8c

Please sign in to comment.