Like setTimeout()
but using requestAnimationFrame()
.
setTimeout
doesn’t take into account what else is happening in the browser.
Source
You can also find requestInterval
component here.
With npm do:
$ npm install nk-request-timeout --save
Install with component(1):
$ component install nk-components/request-timeout
var requestTimeout = require('request-timeout');
requestTimeout(300, function() {
// do something
});
var id = requestTimeout(300, function() {
console.log('should not be executed');
});
setTimeout(function() {
requestTimeout.clear(id);
}, 100);
MIT
Inspired by Joe Lambert's Gist.