API reference › @evolu/common › Task › prioritized
function prioritized<T, E, D>(
priority: TaskPriority,
task: Task<T, E, D>,
): Task<T, E, D>;
Defined in: packages/common/src/Task.ts:4775
Assigns static scheduler priority to a Task.
Run uses the priority with native scheduler.postTask when available.
Platforms without the Scheduler API run the Task normally. Use a Scheduler
API polyfill such as
scheduler-polyfill
for hosts like Safari and React Native when priority-aware scheduling is
needed.
scheduler.postTask must reject queued aborts with AbortSignal.reason.
Other host-specific abort objects are treated as defects.
Example
import { assertOk, createRun, ok, prioritized, type Task } from "@evolu/common";
const rebuildSearchIndex: Task<string> = () => ok("indexed");
const backgroundIndexing = prioritized("background", rebuildSearchIndex);
await using run = createRun();
assertOk(await run(backgroundIndexing), "indexed");