request-timer
v0.1.2
Published
The timer implemented by raf for better performance
Downloads
4
Readme
request-timer
The timer implemented by requestAnimationFrame
for better performance.
How to use
import {
requestTimeout, clearRequestTimeout,
requestInterval, clearRequestInterval
} from 'request-timer'
// delay for 200ms
const timerId = requestTimeout(() => {
// do something cool
}, 200)
// clear timeout if necessary
clearRequestTimeout(timerId)
// execute something every 200ms
const timerId = requestInterval(() => {
// do something cool
}, 200)
// clear interval if necessary
clearRequestInterval(timerId)
It could be used just like setTimeout
and setInterval
.