Background task
An simple function wrapper around requestIdleCallback that queues tasks and runs them sequentially.
The main purpose is to be able to run maintainance functions that are not a good fit for a web worker context.
Usage
Wrap your function.
const task = backgroundTask(() => {
// do stuff
});
Call task as you would any other function that has no return value. The return value of a
background task is the id from requestIdleCallback that can be passed to cancelIdleCallback if
you wish to cancel the task before it runs.
Calling a task multiple times will queue the passed parameters and execute the task sequentially the same number of times.
Description
BackgroundTask is a function wrapper to run maintenance routines in the DOM thread when there is available time.
Languages
JavaScript
100%