Skip to content

Commit 959ceb7

Browse files
committed
WIP: fix tgp
1 parent 3e8d42e commit 959ceb7

File tree

2 files changed

+23
-43
lines changed

2 files changed

+23
-43
lines changed

src/cdk/table/coalesced-style-scheduler.ts

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77
*/
88

99
import {
10+
EnvironmentInjector,
1011
Injectable,
11-
NgZone,
12-
OnDestroy,
1312
InjectionToken,
13+
NgZone,
1414
afterNextRender,
1515
inject,
16-
Injector,
1716
} from '@angular/core';
18-
import {Subject} from 'rxjs';
1917

2018
/**
2119
* @docs-private
@@ -38,13 +36,11 @@ export const _COALESCED_STYLE_SCHEDULER = new InjectionToken<_CoalescedStyleSche
3836
* @docs-private
3937
*/
4038
@Injectable()
41-
export class _CoalescedStyleScheduler implements OnDestroy {
39+
export class _CoalescedStyleScheduler {
4240
private _currentSchedule: _Schedule | null = null;
43-
private readonly _destroyed = new Subject<void>();
44-
private _isDestroyed = false;
45-
private _injector = inject(Injector);
41+
private _injector = inject(EnvironmentInjector);
4642

47-
constructor(private readonly _ngZone: NgZone) {}
43+
constructor(_unusedNgZone?: NgZone) {}
4844

4945
/**
5046
* Schedules the specified task to run at the end of the current VM turn.
@@ -65,48 +61,33 @@ export class _CoalescedStyleScheduler implements OnDestroy {
6561
this._currentSchedule!.endTasks.push(task);
6662
}
6763

68-
/** Prevent any further tasks from running. */
69-
ngOnDestroy() {
70-
this._destroyed.next();
71-
this._destroyed.complete();
72-
this._isDestroyed = true;
73-
}
74-
7564
private _createScheduleIfNeeded() {
7665
if (this._currentSchedule) {
7766
return;
7867
}
7968

8069
this._currentSchedule = new _Schedule();
8170

82-
this._ngZone.run(() =>
83-
queueMicrotask(() => {
84-
if (this._isDestroyed) {
85-
return;
86-
}
87-
88-
afterNextRender(
89-
() => {
90-
while (this._currentSchedule!.tasks.length || this._currentSchedule!.endTasks.length) {
91-
const schedule = this._currentSchedule!;
71+
afterNextRender(
72+
() => {
73+
while (this._currentSchedule!.tasks.length || this._currentSchedule!.endTasks.length) {
74+
const schedule = this._currentSchedule!;
9275

93-
// Capture new tasks scheduled by the current set of tasks.
94-
this._currentSchedule = new _Schedule();
76+
// Capture new tasks scheduled by the current set of tasks.
77+
this._currentSchedule = new _Schedule();
9578

96-
for (const task of schedule.tasks) {
97-
task();
98-
}
79+
for (const task of schedule.tasks) {
80+
task();
81+
}
9982

100-
for (const task of schedule.endTasks) {
101-
task();
102-
}
103-
}
83+
for (const task of schedule.endTasks) {
84+
task();
85+
}
86+
}
10487

105-
this._currentSchedule = null;
106-
},
107-
{injector: this._injector},
108-
);
109-
}),
88+
this._currentSchedule = null;
89+
},
90+
{injector: this._injector},
11091
);
11192
}
11293
}

tools/public_api_guard/cdk/table.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,8 @@ export interface CellDef {
439439
export const _COALESCED_STYLE_SCHEDULER: InjectionToken<_CoalescedStyleScheduler>;
440440

441441
// @public
442-
export class _CoalescedStyleScheduler implements OnDestroy {
443-
constructor(_ngZone: NgZone);
444-
ngOnDestroy(): void;
442+
export class _CoalescedStyleScheduler {
443+
constructor(_unusedNgZone?: NgZone);
445444
schedule(task: () => unknown): void;
446445
scheduleEnd(task: () => unknown): void;
447446
// (undocumented)

0 commit comments

Comments
 (0)