From 959ceb7e079b45652dcd144a88545d5fae8c2707 Mon Sep 17 00:00:00 2001 From: Miles Malerba Date: Thu, 21 Mar 2024 18:39:05 -0700 Subject: [PATCH] WIP: fix tgp --- src/cdk/table/coalesced-style-scheduler.ts | 61 ++++++++-------------- tools/public_api_guard/cdk/table.md | 5 +- 2 files changed, 23 insertions(+), 43 deletions(-) diff --git a/src/cdk/table/coalesced-style-scheduler.ts b/src/cdk/table/coalesced-style-scheduler.ts index ba20be4549cb..f67b4871fbef 100644 --- a/src/cdk/table/coalesced-style-scheduler.ts +++ b/src/cdk/table/coalesced-style-scheduler.ts @@ -7,15 +7,13 @@ */ import { + EnvironmentInjector, Injectable, - NgZone, - OnDestroy, InjectionToken, + NgZone, afterNextRender, inject, - Injector, } from '@angular/core'; -import {Subject} from 'rxjs'; /** * @docs-private @@ -38,13 +36,11 @@ export const _COALESCED_STYLE_SCHEDULER = new InjectionToken<_CoalescedStyleSche * @docs-private */ @Injectable() -export class _CoalescedStyleScheduler implements OnDestroy { +export class _CoalescedStyleScheduler { private _currentSchedule: _Schedule | null = null; - private readonly _destroyed = new Subject(); - private _isDestroyed = false; - private _injector = inject(Injector); + private _injector = inject(EnvironmentInjector); - constructor(private readonly _ngZone: NgZone) {} + constructor(_unusedNgZone?: NgZone) {} /** * Schedules the specified task to run at the end of the current VM turn. @@ -65,13 +61,6 @@ export class _CoalescedStyleScheduler implements OnDestroy { this._currentSchedule!.endTasks.push(task); } - /** Prevent any further tasks from running. */ - ngOnDestroy() { - this._destroyed.next(); - this._destroyed.complete(); - this._isDestroyed = true; - } - private _createScheduleIfNeeded() { if (this._currentSchedule) { return; @@ -79,34 +68,26 @@ export class _CoalescedStyleScheduler implements OnDestroy { this._currentSchedule = new _Schedule(); - this._ngZone.run(() => - queueMicrotask(() => { - if (this._isDestroyed) { - return; - } - - afterNextRender( - () => { - while (this._currentSchedule!.tasks.length || this._currentSchedule!.endTasks.length) { - const schedule = this._currentSchedule!; + afterNextRender( + () => { + while (this._currentSchedule!.tasks.length || this._currentSchedule!.endTasks.length) { + const schedule = this._currentSchedule!; - // Capture new tasks scheduled by the current set of tasks. - this._currentSchedule = new _Schedule(); + // Capture new tasks scheduled by the current set of tasks. + this._currentSchedule = new _Schedule(); - for (const task of schedule.tasks) { - task(); - } + for (const task of schedule.tasks) { + task(); + } - for (const task of schedule.endTasks) { - task(); - } - } + for (const task of schedule.endTasks) { + task(); + } + } - this._currentSchedule = null; - }, - {injector: this._injector}, - ); - }), + this._currentSchedule = null; + }, + {injector: this._injector}, ); } } diff --git a/tools/public_api_guard/cdk/table.md b/tools/public_api_guard/cdk/table.md index 779718db646c..3587400512f0 100644 --- a/tools/public_api_guard/cdk/table.md +++ b/tools/public_api_guard/cdk/table.md @@ -439,9 +439,8 @@ export interface CellDef { export const _COALESCED_STYLE_SCHEDULER: InjectionToken<_CoalescedStyleScheduler>; // @public -export class _CoalescedStyleScheduler implements OnDestroy { - constructor(_ngZone: NgZone); - ngOnDestroy(): void; +export class _CoalescedStyleScheduler { + constructor(_unusedNgZone?: NgZone); schedule(task: () => unknown): void; scheduleEnd(task: () => unknown): void; // (undocumented)