Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. CO(from @gravityboy) Thanks ben that is a great answer. It does a setimeout 4 times then beat() will only call someaction() if it is over the threshold number, correct? What happens if it is called a few milliseconds before the threshold of 430? Then it doesn't get another chance to fire until it waits out the 107 timeout again? What do you think is the smallest number that can be used in the setTimeout?
      singulars
    2. CO(from @gravityboy continued) Also what do you think about just having a loop without a setimeout, just using... var currentTime = +new Date; var delta = currentTime - pastTime; and it will run and check delta at whatever speed the computer will allow? Literally hundreds of times then call the function when delta is exceded. Is that a runaway loop? p.s. I thought the = +new Date was a typo but is is not. It displays the date in milliseconds? I can't even find that documented anywhere.
      singulars
    3. COYes, you're correct that this could lead to a 100ms delay. This is just a tradeoff in terms of app responsiveness and timer accuracy. If you did `setTimeout` with 0ms, it will execute the fastest the browser allows (~14ms in some), and this will provide the finest resolution, and thus the greatest accuracy. However, this will come at the expense of the rest of your app. For something simple, this should work great, but for complex apps, this might not work so well.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload