Skip to content

Commit 9b5a29e

Browse files
authored
Merge pull request #136 from nolanlawson/user-visible
Use default priority for `scheduler.postTask`
2 parents 6c67ff5 + 4ac3ab9 commit 9b5a29e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/lib/scheduling.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ interface Scheduler {
2626
}
2727
declare const scheduler: Scheduler;
2828

29-
// 'user-blocking' runs right after microtasks, so equivalent to setTimeout but without the 4ms clamping
29+
// 'postTask' runs right after microtasks, so equivalent to setTimeout but without the 4ms clamping.
30+
// Using the default priority of 'user-visible' to avoid blocking input while still running fairly quickly.
31+
// See: https://developer.mozilla.org/en-US/docs/Web/API/Prioritized_Task_Scheduling_API#task_priorities
3032
const schedulerPostTask =
3133
typeof scheduler !== "undefined" &&
32-
((fn: () => void) => scheduler.postTask(fn, { priority: "user-blocking" }));
34+
((fn: () => void) => scheduler.postTask(fn));
3335

3436
// fallback for environments that don't support any of the above
3537
const doSetTimeout = (fn: () => void) => setTimeout(fn, 0);

0 commit comments

Comments
 (0)