Hacker News new | past | comments | ask | show | jobs | submit login

Resetting the interval when the delay changes is probably not what you want either -- quickly changing the delay (even a little bit) won't give the timer a chance to fire. It would be better to compute a deadline internally, then move the deadline forward or backward according to how much the delay changed since the last call.



Good thing something like useInterval() can abstract these implementation details away so it can be made more precise with time. :-)


A setInterval/setTimeout can only be cleared (clearInterval/clearTimeout). Modifications have to pushed through clear -> set.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: