Files
iD/modules/util/call_when_idle.js
Kushan Joshi 909b72a39e cleaning up
2017-08-24 17:03:04 +05:30

12 lines
341 B
JavaScript

// note the function should be of low priority
// and should not be returning a value.
export function utilCallWhenIdle(func, timeout) {
return function() {
var args = arguments;
var that = this;
window.requestIdleCallback(function() {
func.apply(that, args);
}, {timeout: timeout});
};
}