API reference / @evolu/common / Task / requestIdleTask
Function: requestIdleTask()
function requestIdleTask<T, E>(task): Task<T, E>;
Defined in: packages/common/src/Task.ts:766
Schedule a task to run after all interactions (animations, gestures, navigation) have completed.
This uses requestIdleCallback when available, otherwise falls back to
setTimeout(0) for cross-platform compatibility.
Example
const processDataTask: Task<void, ProcessError> = toTask(async () => {
// Heavy processing work
return ok();
});
// Schedule the task to run when idle
void requestIdleTask(processDataTask)();
Type Parameters
| Type Parameter |
|---|
T |
E |
Parameters
| Parameter | Type |
|---|---|
task | Task<T, E> |
Returns
Task<T, E>