Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0728e5d

Browse files
committed
feat(cdk): add native postTask scheduling support
1 parent 4055fb2 commit 0728e5d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

libs/cdk/internals/scheduler/src/lib/scheduler.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ import { PriorityLevel } from './schedulerPriorities';
1818
*/
1919
declare const ngDevMode: boolean;
2020

21+
const isPostTaskSupported =
22+
typeof ɵglobal.scheduler !== 'undefined' &&
23+
typeof ɵglobal.scheduler.postTask === 'function';
24+
2125
let getCurrentTime: () => number;
2226
const hasPerformanceNow =
2327
typeof ɵglobal.performance === 'object' &&
@@ -561,7 +565,9 @@ if (typeof setImmediate === 'function') {
561565

562566
function requestHostCallback(callback) {
563567
scheduledHostCallback = callback;
564-
if (!isMessageLoopRunning) {
568+
if (isPostTaskSupported) {
569+
ɵglobal.scheduler.postTask(performWorkUntilDeadline);
570+
} else if (!isMessageLoopRunning) {
565571
isMessageLoopRunning = true;
566572
schedulePerformWorkUntilDeadline();
567573
}

0 commit comments

Comments
 (0)