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

Skip to content

Commit 521760d

Browse files
committed
feat(cdk): add native postTask scheduling support
1 parent fe68f6f commit 521760d

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

libs/cdk/render-strategies/src/lib/concurrent-strategies.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,37 @@ const idleStrategy: RxStrategyCredentials = {
9292
};
9393

9494
const postTaskUserVisibleStrategy: RxStrategyCredentials = {
95-
name: 'userVisible',
95+
name: 'postTaskUserVisible',
96+
work: (cdRef) => cdRef.detectChanges(),
97+
behavior: ({ work, scope, ngZone }) => {
98+
return (o$) =>
99+
o$.pipe(
100+
scheduleOnPostTaskQueue(work, {
101+
ngZone,
102+
priority: PriorityLevel.NormalPriority,
103+
scope,
104+
})
105+
);
106+
},
107+
};
108+
109+
const postTaskUserBlockingStrategy: RxStrategyCredentials = {
110+
name: 'postTaskUserBlocking',
111+
work: (cdRef) => cdRef.detectChanges(),
112+
behavior: ({ work, scope, ngZone }) => {
113+
return (o$) =>
114+
o$.pipe(
115+
scheduleOnPostTaskQueue(work, {
116+
ngZone,
117+
priority: PriorityLevel.UserBlockingPriority,
118+
scope,
119+
})
120+
);
121+
},
122+
};
123+
124+
const postTaskBackgroundStrategy: RxStrategyCredentials = {
125+
name: 'postTaskBackground',
96126
work: (cdRef) => cdRef.detectChanges(),
97127
behavior: ({ work, scope, ngZone }) => {
98128
return (o$) =>
@@ -181,5 +211,7 @@ export const RX_CONCURRENT_STRATEGIES: RxConcurrentStrategies = {
181211
normal: normalStrategy,
182212
low: lowStrategy,
183213
idle: idleStrategy,
184-
userVisible: postTaskUserVisibleStrategy,
214+
postTaskUserVisible: postTaskUserVisibleStrategy,
215+
postTaskUserBlocking: postTaskUserBlockingStrategy,
216+
postTaskBackground: postTaskBackgroundStrategy,
185217
};

libs/cdk/render-strategies/src/lib/model.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export type RxConcurrentStrategyNames =
3737
| 'normal'
3838
| 'low'
3939
| 'idle'
40-
| 'userVisible';
40+
| 'postTaskUserVisible'
41+
| 'postTaskUserBlocking'
42+
| 'postTaskBackground';
4143
export type RxDefaultStrategyNames =
4244
| RxNativeStrategyNames
4345
| RxConcurrentStrategyNames;

0 commit comments

Comments
 (0)