-
Notifications
You must be signed in to change notification settings - Fork 14
Allow requesting a minimum time budget #49
Copy link
Copy link
Open
Labels
Milestone
Description
I my experience every use of requestIdleCallback will eventually have a wrapper like this one:
function requestIdleCallback(win, minimumTimeRemaining, timeout, fn) {
const before = Date.now();
win.requestIdleCallback(info => {
if (info.timeRemaining() < minimumTimeRemaining) {
const remainingTimeout = timeout - (Date.now() - before);
if (remainingTimeout <= 0) {
fn();
} else {
requestIdleCallback(win, minimumTimeRemaining, remainingTimeout, fn);
}
} else {
fn();
}
});
}…where rIC is called recursively until a time budget under some requirement is reached. Among other things this requires managing the timeout in user code, because one will typically want a timeout across these calls.
This would be fixed by allowing the caller to pass in something like minimumTimeRemaining into the rIC options object.
Reactions are currently unavailable