Skip to content

Commit 8cf3a72

Browse files
SkyZeroZxthePunderWoman
authored andcommitted
refactor(core): Add missing OnDestroy to zone and zoneless change detection schedulers
Implements the OnDestroy interface in NgZoneChangeDetectionScheduler and ChangeDetectionSchedulerImpl (cherry picked from commit fa6e82b)
1 parent 481557e commit 8cf3a72

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/core/src/change_detection/scheduling/ng_zone_scheduling.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ import {
3131
} from './zoneless_scheduling';
3232
import {SCHEDULE_IN_ROOT_ZONE_DEFAULT} from './flags';
3333
import {INTERNAL_APPLICATION_ERROR_HANDLER} from '../../error_handler';
34+
import {OnDestroy} from '../lifecycle_hooks';
3435

3536
@Injectable({providedIn: 'root'})
36-
export class NgZoneChangeDetectionScheduler {
37+
export class NgZoneChangeDetectionScheduler implements OnDestroy {
3738
private readonly zone = inject(NgZone);
3839
private readonly changeDetectionScheduler = inject(ChangeDetectionScheduler);
3940
private readonly applicationRef = inject(ApplicationRef);

packages/core/src/change_detection/scheduling/zoneless_scheduling_impl.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
} from './zoneless_scheduling';
3232
import {TracingService} from '../../application/tracing';
3333
import {INTERNAL_APPLICATION_ERROR_HANDLER} from '../../error_handler';
34+
import {OnDestroy} from '../lifecycle_hooks';
3435

3536
const CONSECUTIVE_MICROTASK_NOTIFICATION_LIMIT = 100;
3637
let consecutiveMicrotaskNotifications = 0;
@@ -56,7 +57,7 @@ function trackMicrotaskNotificationForDebugging() {
5657
}
5758

5859
@Injectable({providedIn: 'root'})
59-
export class ChangeDetectionSchedulerImpl implements ChangeDetectionScheduler {
60+
export class ChangeDetectionSchedulerImpl implements ChangeDetectionScheduler, OnDestroy {
6061
private readonly applicationErrorHandler = inject(INTERNAL_APPLICATION_ERROR_HANDLER);
6162
private readonly appRef = inject(ApplicationRef);
6263
private readonly taskService = inject(PendingTasksInternal);

0 commit comments

Comments
 (0)