Self correction
Last updated
Was this helpful?
Last updated
Was this helpful?
selfCorrecting
boolean
true
Self correct time intervals between subsequent invocations to reflect actual time elapsed.
setTimeout and setInterval are not precise () which make them unusable in their basic form for functionalities that strictly depend on precise timing (like clocks, timers or time based events).
This option helps eliminating that problem by depending on absolute timestamps and auto adjusting time between each .
If you disable that option you will get same behaviour as using barebone setInterval but still using the advantage of .
Let's say you set to 1000 ms. Internally it will set setTimeout(..., 1000).
But then it turns out that setTimeout actually took 1005 ms to call instead of 1000 ms. Now the self correction kicks in and the next setTimeout will be automatically set to 995 ms to compensate for a 5 ms drift.
This process will be repeated every interval.
But what if setTimeout take 5000 ms instead of 1005 ms? Not to worry, this case can be handled in by using ticks to indicate how many intervals has passed since last callback.